@backstage/plugin-scaffolder-backend-module-bitbucket 0.3.8-next.1 → 0.3.8

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,33 @@
1
1
  # @backstage/plugin-scaffolder-backend-module-bitbucket
2
2
 
3
+ ## 0.3.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 4f8b5b6: Allow signing git commits using configured private PGP key in scaffolder
8
+ - Updated dependencies
9
+ - @backstage/integration@1.16.2
10
+ - @backstage/plugin-scaffolder-backend-module-bitbucket-cloud@0.2.7
11
+ - @backstage/plugin-scaffolder-node@0.8.0
12
+ - @backstage/plugin-scaffolder-backend-module-bitbucket-server@0.2.7
13
+ - @backstage/backend-plugin-api@1.2.1
14
+ - @backstage/config@1.3.2
15
+ - @backstage/errors@1.2.7
16
+
17
+ ## 0.3.8-next.2
18
+
19
+ ### Patch Changes
20
+
21
+ - 4f8b5b6: Allow signing git commits using configured private PGP key in scaffolder
22
+ - Updated dependencies
23
+ - @backstage/plugin-scaffolder-backend-module-bitbucket-cloud@0.2.7-next.2
24
+ - @backstage/plugin-scaffolder-node@0.8.0-next.2
25
+ - @backstage/plugin-scaffolder-backend-module-bitbucket-server@0.2.7-next.2
26
+ - @backstage/integration@1.16.2-next.0
27
+ - @backstage/backend-plugin-api@1.2.1-next.1
28
+ - @backstage/config@1.3.2
29
+ - @backstage/errors@1.2.7
30
+
3
31
  ## 0.3.8-next.1
4
32
 
5
33
  ### Patch Changes
@@ -184,6 +184,11 @@ function createPublishBitbucketAction(options) {
184
184
  title: "Default Author Email",
185
185
  type: "string",
186
186
  description: `Sets the default author email for the commit.`
187
+ },
188
+ signCommit: {
189
+ title: "Sign commit",
190
+ type: "boolean",
191
+ description: "Sign commit with configured PGP private key"
187
192
  }
188
193
  }
189
194
  },
@@ -217,7 +222,8 @@ function createPublishBitbucketAction(options) {
217
222
  enableLFS = false,
218
223
  gitCommitMessage = "initial commit",
219
224
  gitAuthorName,
220
- gitAuthorEmail
225
+ gitAuthorEmail,
226
+ signCommit
221
227
  } = ctx.input;
222
228
  const { workspace, project, repo, host } = pluginScaffolderNode.parseRepoUrl(
223
229
  repoUrl,
@@ -264,6 +270,12 @@ function createPublishBitbucketAction(options) {
264
270
  name: gitAuthorName ? gitAuthorName : config.getOptionalString("scaffolder.defaultAuthor.name"),
265
271
  email: gitAuthorEmail ? gitAuthorEmail : config.getOptionalString("scaffolder.defaultAuthor.email")
266
272
  };
273
+ const signingKey = integrationConfig.config.commitSigningKey ?? config.getOptionalString("scaffolder.defaultCommitSigningKey");
274
+ if (signCommit && !signingKey) {
275
+ throw new Error(
276
+ "Signing commits is enabled but no signing key is provided in the configuration"
277
+ );
278
+ }
267
279
  let auth;
268
280
  if (ctx.input.token) {
269
281
  auth = {
@@ -283,7 +295,8 @@ function createPublishBitbucketAction(options) {
283
295
  defaultBranch,
284
296
  logger: ctx.logger,
285
297
  commitMessage: gitCommitMessage ? gitCommitMessage : config.getOptionalString("scaffolder.defaultCommitMessage"),
286
- gitAuthorInfo
298
+ gitAuthorInfo,
299
+ signingKey: signCommit ? signingKey : void 0
287
300
  });
288
301
  if (enableLFS && host !== "bitbucket.org") {
289
302
  await performEnableLFS({ authorization, host, project, repo });
@@ -1 +1 @@
1
- {"version":3,"file":"bitbucket.cjs.js","sources":["../../src/actions/bitbucket.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport {\n BitbucketIntegrationConfig,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n initRepoAndPush,\n getRepoSourceDirectory,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Config } from '@backstage/config';\nimport { examples } from './bitbucket.examples';\n\nconst createBitbucketCloudRepository = 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\nconst createBitbucketServerRepository = async (opts: {\n project: string;\n repo: string;\n description?: string;\n repoVisibility: 'private' | 'public';\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const {\n project,\n repo,\n description,\n authorization,\n repoVisibility,\n apiBaseUrl,\n } = opts;\n\n let response: Response;\n const options: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n name: repo,\n description: description,\n public: repoVisibility === 'public',\n }),\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(`${apiBaseUrl}/projects/${project}/repos`, options);\n } catch (e) {\n throw new Error(`Unable to create repository, ${e}`);\n }\n\n if (response.status !== 201) {\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 === 'http') {\n remoteUrl = link.href;\n }\n }\n\n const repoContentsUrl = `${r.links.self[0].href}`;\n return { remoteUrl, repoContentsUrl };\n};\n\nconst getAuthorizationHeader = (config: BitbucketIntegrationConfig) => {\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. Please add either username + appPassword or token to the Integrations config`,\n );\n};\n\nconst performEnableLFS = async (opts: {\n authorization: string;\n host: string;\n project: string;\n repo: string;\n}) => {\n const { authorization, host, project, repo } = opts;\n\n const options: RequestInit = {\n method: 'PUT',\n headers: {\n Authorization: authorization,\n },\n };\n\n const { ok, status, statusText } = await fetch(\n `https://${host}/rest/git-lfs/admin/projects/${project}/repos/${repo}/enabled`,\n options,\n );\n\n if (!ok)\n throw new Error(\n `Failed to enable LFS in the repository, ${status}: ${statusText}`,\n );\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.\n * @public\n * @deprecated in favor of \"createPublishBitbucketCloudAction\" by \\@backstage/plugin-scaffolder-backend-module-bitbucket-cloud and \"createPublishBitbucketServerAction\" by \\@backstage/plugin-scaffolder-backend-module-bitbucket-server\n */\nexport function createPublishBitbucketAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n description?: string;\n defaultBranch?: string;\n repoVisibility?: 'private' | 'public';\n sourcePath?: string;\n enableLFS?: boolean;\n token?: string;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n }>({\n id: 'publish:bitbucket',\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to Bitbucket.',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n description: {\n title: 'Repository Description',\n type: 'string',\n },\n repoVisibility: {\n title: 'Repository Visibility',\n type: 'string',\n enum: ['private', 'public'],\n },\n defaultBranch: {\n title: 'Default Branch',\n type: 'string',\n description: `Sets the default branch on the repository. The default value is 'master'`,\n },\n sourcePath: {\n title: 'Source Path',\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 type: 'string',\n },\n enableLFS: {\n title: 'Enable LFS?',\n description:\n 'Enable LFS for the repository. Only available for hosted Bitbucket.',\n type: 'boolean',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to BitBucket',\n },\n gitCommitMessage: {\n title: 'Git Commit Message',\n type: 'string',\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n },\n gitAuthorName: {\n title: 'Default Author Name',\n type: 'string',\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n },\n gitAuthorEmail: {\n title: 'Default Author Email',\n type: 'string',\n description: `Sets the default author email for the commit.`,\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n remoteUrl: {\n title: 'A URL to the repository with the provider',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the root of the repository',\n type: 'string',\n },\n commitHash: {\n title: 'The git commit hash of the initial commit',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n ctx.logger.warn(\n `[Deprecated] Please migrate the use of action \"publish:bitbucket\" to \"publish:bitbucketCloud\" or \"publish:bitbucketServer\".`,\n );\n const {\n repoUrl,\n description,\n defaultBranch = 'master',\n repoVisibility = 'private',\n enableLFS = false,\n gitCommitMessage = 'initial commit',\n gitAuthorName,\n gitAuthorEmail,\n } = ctx.input;\n\n const { workspace, project, repo, host } = parseRepoUrl(\n repoUrl,\n integrations,\n );\n\n // Workspace is only required for bitbucket cloud\n if (host === 'bitbucket.org') {\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\n // Project is required for both bitbucket cloud and bitbucket server\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.bitbucket.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n const authorization = getAuthorizationHeader(\n ctx.input.token\n ? {\n host: integrationConfig.config.host,\n apiBaseUrl: integrationConfig.config.apiBaseUrl,\n token: ctx.input.token,\n }\n : integrationConfig.config,\n );\n\n const apiBaseUrl = integrationConfig.config.apiBaseUrl;\n\n const createMethod =\n host === 'bitbucket.org'\n ? createBitbucketCloudRepository\n : createBitbucketServerRepository;\n\n const { remoteUrl, repoContentsUrl } = await createMethod({\n authorization,\n workspace: workspace || '',\n project,\n repo,\n repoVisibility,\n mainBranch: defaultBranch,\n description,\n apiBaseUrl,\n });\n\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : 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 auth = {\n username: integrationConfig.config.username\n ? integrationConfig.config.username\n : 'x-token-auth',\n password: integrationConfig.config.appPassword\n ? integrationConfig.config.appPassword\n : integrationConfig.config.token ?? '',\n };\n }\n\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),\n remoteUrl,\n auth,\n defaultBranch,\n logger: ctx.logger,\n commitMessage: gitCommitMessage\n ? gitCommitMessage\n : config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n });\n\n if (enableLFS && host !== 'bitbucket.org') {\n await performEnableLFS({ authorization, host, project, repo });\n }\n\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;AA8BA,MAAM,8BAAA,GAAiC,OAAO,IASxC,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,KAAA;AAAA,MACL,WAAA;AAAA,MACA,YAAY,cAAmB,KAAA,SAAA;AAAA,MAC/B,OAAA,EAAS,EAAE,GAAA,EAAK,OAAQ;AAAA,KACzB,CAAA;AAAA,IACD,OAAS,EAAA;AAAA,MACP,aAAe,EAAA,aAAA;AAAA,MACf,cAAgB,EAAA;AAAA;AAClB,GACF;AAEA,EAAI,IAAA,QAAA;AACJ,EAAI,IAAA;AACF,IAAA,QAAA,GAAW,MAAM,KAAA;AAAA,MACf,CAAG,EAAA,UAAU,CAAiB,cAAA,EAAA,SAAS,IAAI,IAAI,CAAA,CAAA;AAAA,MAC/C;AAAA,KACF;AAAA,WACO,CAAG,EAAA;AACV,IAAA,MAAM,IAAI,KAAA,CAAM,CAAgC,6BAAA,EAAA,CAAC,CAAE,CAAA,CAAA;AAAA;AAGrD,EAAI,IAAA,QAAA,CAAS,WAAW,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;AAGF,MAAM,MAAA,YAAA,GAAe,MAAMC,oCAAgB,CAAA;AAAA,QACzC,KAAKC,2CAAuB,CAAA,GAAA,CAAI,aAAe,EAAA,GAAA,CAAI,MAAM,UAAU,CAAA;AAAA,QACnE,SAAA;AAAA,QACA,IAAA;AAAA,QACA,aAAA;AAAA,QACA,QAAQ,GAAI,CAAA,MAAA;AAAA,QACZ,aAAe,EAAA,gBAAA,GACX,gBACA,GAAA,MAAA,CAAO,kBAAkB,iCAAiC,CAAA;AAAA,QAC9D;AAAA,OACD,CAAA;AAED,MAAI,IAAA,SAAA,IAAa,SAAS,eAAiB,EAAA;AACzC,QAAA,MAAM,iBAAiB,EAAE,aAAA,EAAe,IAAM,EAAA,OAAA,EAAS,MAAM,CAAA;AAAA;AAG/D,MAAI,GAAA,CAAA,MAAA,CAAO,YAAc,EAAA,YAAA,EAAc,UAAU,CAAA;AACjD,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":"bitbucket.cjs.js","sources":["../../src/actions/bitbucket.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InputError } from '@backstage/errors';\nimport {\n BitbucketIntegrationConfig,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n getRepoSourceDirectory,\n initRepoAndPush,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport { Config } from '@backstage/config';\nimport { examples } from './bitbucket.examples';\n\nconst createBitbucketCloudRepository = 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\nconst createBitbucketServerRepository = async (opts: {\n project: string;\n repo: string;\n description?: string;\n repoVisibility: 'private' | 'public';\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const {\n project,\n repo,\n description,\n authorization,\n repoVisibility,\n apiBaseUrl,\n } = opts;\n\n let response: Response;\n const options: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n name: repo,\n description: description,\n public: repoVisibility === 'public',\n }),\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(`${apiBaseUrl}/projects/${project}/repos`, options);\n } catch (e) {\n throw new Error(`Unable to create repository, ${e}`);\n }\n\n if (response.status !== 201) {\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 === 'http') {\n remoteUrl = link.href;\n }\n }\n\n const repoContentsUrl = `${r.links.self[0].href}`;\n return { remoteUrl, repoContentsUrl };\n};\n\nconst getAuthorizationHeader = (config: BitbucketIntegrationConfig) => {\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. Please add either username + appPassword or token to the Integrations config`,\n );\n};\n\nconst performEnableLFS = async (opts: {\n authorization: string;\n host: string;\n project: string;\n repo: string;\n}) => {\n const { authorization, host, project, repo } = opts;\n\n const options: RequestInit = {\n method: 'PUT',\n headers: {\n Authorization: authorization,\n },\n };\n\n const { ok, status, statusText } = await fetch(\n `https://${host}/rest/git-lfs/admin/projects/${project}/repos/${repo}/enabled`,\n options,\n );\n\n if (!ok)\n throw new Error(\n `Failed to enable LFS in the repository, ${status}: ${statusText}`,\n );\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.\n * @public\n * @deprecated in favor of \"createPublishBitbucketCloudAction\" by \\@backstage/plugin-scaffolder-backend-module-bitbucket-cloud and \"createPublishBitbucketServerAction\" by \\@backstage/plugin-scaffolder-backend-module-bitbucket-server\n */\nexport function createPublishBitbucketAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n description?: string;\n defaultBranch?: string;\n repoVisibility?: 'private' | 'public';\n sourcePath?: string;\n enableLFS?: boolean;\n token?: string;\n gitCommitMessage?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n signCommit?: boolean;\n }>({\n id: 'publish:bitbucket',\n description:\n 'Initializes a git repository of the content in the workspace, and publishes it to Bitbucket.',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n description: {\n title: 'Repository Description',\n type: 'string',\n },\n repoVisibility: {\n title: 'Repository Visibility',\n type: 'string',\n enum: ['private', 'public'],\n },\n defaultBranch: {\n title: 'Default Branch',\n type: 'string',\n description: `Sets the default branch on the repository. The default value is 'master'`,\n },\n sourcePath: {\n title: 'Source Path',\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 type: 'string',\n },\n enableLFS: {\n title: 'Enable LFS?',\n description:\n 'Enable LFS for the repository. Only available for hosted Bitbucket.',\n type: 'boolean',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to BitBucket',\n },\n gitCommitMessage: {\n title: 'Git Commit Message',\n type: 'string',\n description: `Sets the commit message on the repository. The default value is 'initial commit'`,\n },\n gitAuthorName: {\n title: 'Default Author Name',\n type: 'string',\n description: `Sets the default author name for the commit. The default value is 'Scaffolder'`,\n },\n gitAuthorEmail: {\n title: 'Default Author Email',\n type: 'string',\n description: `Sets the default author email for the commit.`,\n },\n signCommit: {\n title: 'Sign commit',\n type: 'boolean',\n description: 'Sign commit with configured PGP private key',\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n remoteUrl: {\n title: 'A URL to the repository with the provider',\n type: 'string',\n },\n repoContentsUrl: {\n title: 'A URL to the root of the repository',\n type: 'string',\n },\n commitHash: {\n title: 'The git commit hash of the initial commit',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n ctx.logger.warn(\n `[Deprecated] Please migrate the use of action \"publish:bitbucket\" to \"publish:bitbucketCloud\" or \"publish:bitbucketServer\".`,\n );\n const {\n repoUrl,\n description,\n defaultBranch = 'master',\n repoVisibility = 'private',\n enableLFS = false,\n gitCommitMessage = 'initial commit',\n gitAuthorName,\n gitAuthorEmail,\n signCommit,\n } = ctx.input;\n\n const { workspace, project, repo, host } = parseRepoUrl(\n repoUrl,\n integrations,\n );\n\n // Workspace is only required for bitbucket cloud\n if (host === 'bitbucket.org') {\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\n // Project is required for both bitbucket cloud and bitbucket server\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.bitbucket.byHost(host);\n\n if (!integrationConfig) {\n throw new InputError(\n `No matching integration configuration for host ${host}, please check your integrations config`,\n );\n }\n\n const authorization = getAuthorizationHeader(\n ctx.input.token\n ? {\n host: integrationConfig.config.host,\n apiBaseUrl: integrationConfig.config.apiBaseUrl,\n token: ctx.input.token,\n }\n : integrationConfig.config,\n );\n\n const apiBaseUrl = integrationConfig.config.apiBaseUrl;\n\n const createMethod =\n host === 'bitbucket.org'\n ? createBitbucketCloudRepository\n : createBitbucketServerRepository;\n\n const { remoteUrl, repoContentsUrl } = await createMethod({\n authorization,\n workspace: workspace || '',\n project,\n repo,\n repoVisibility,\n mainBranch: defaultBranch,\n description,\n apiBaseUrl,\n });\n\n const gitAuthorInfo = {\n name: gitAuthorName\n ? gitAuthorName\n : config.getOptionalString('scaffolder.defaultAuthor.name'),\n email: gitAuthorEmail\n ? gitAuthorEmail\n : config.getOptionalString('scaffolder.defaultAuthor.email'),\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 let auth;\n\n if (ctx.input.token) {\n auth = {\n username: 'x-token-auth',\n password: ctx.input.token,\n };\n } else {\n auth = {\n username: integrationConfig.config.username\n ? integrationConfig.config.username\n : 'x-token-auth',\n password: integrationConfig.config.appPassword\n ? integrationConfig.config.appPassword\n : integrationConfig.config.token ?? '',\n };\n }\n\n const commitResult = await initRepoAndPush({\n dir: getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),\n remoteUrl,\n auth,\n defaultBranch,\n logger: ctx.logger,\n commitMessage: gitCommitMessage\n ? gitCommitMessage\n : config.getOptionalString('scaffolder.defaultCommitMessage'),\n gitAuthorInfo,\n signingKey: signCommit ? signingKey : undefined,\n });\n\n if (enableLFS && host !== 'bitbucket.org') {\n await performEnableLFS({ authorization, host, project, repo });\n }\n\n ctx.output('commitHash', commitResult?.commitHash);\n ctx.output('remoteUrl', remoteUrl);\n ctx.output('repoContentsUrl', repoContentsUrl);\n },\n });\n}\n"],"names":["createTemplateAction","examples","parseRepoUrl","InputError","initRepoAndPush","getRepoSourceDirectory"],"mappings":";;;;;;AA8BA,MAAM,8BAAA,GAAiC,OAAO,IASxC,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,KAAA;AAAA,MACL,WAAA;AAAA,MACA,YAAY,cAAmB,KAAA,SAAA;AAAA,MAC/B,OAAA,EAAS,EAAE,GAAA,EAAK,OAAQ;AAAA,KACzB,CAAA;AAAA,IACD,OAAS,EAAA;AAAA,MACP,aAAe,EAAA,aAAA;AAAA,MACf,cAAgB,EAAA;AAAA;AAClB,GACF;AAEA,EAAI,IAAA,QAAA;AACJ,EAAI,IAAA;AACF,IAAA,QAAA,GAAW,MAAM,KAAA;AAAA,MACf,CAAG,EAAA,UAAU,CAAiB,cAAA,EAAA,SAAS,IAAI,IAAI,CAAA,CAAA;AAAA,MAC/C;AAAA,KACF;AAAA,WACO,CAAG,EA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ED
@@ -1,10 +1,10 @@
1
1
  import * as _backstage_plugin_scaffolder_node from '@backstage/plugin-scaffolder-node';
2
- import * as _backstage_types from '@backstage/types';
3
2
  import * as _backstage_integration from '@backstage/integration';
4
3
  import { ScmIntegrationRegistry } from '@backstage/integration';
5
4
  import * as bitbucketCloud from '@backstage/plugin-scaffolder-backend-module-bitbucket-cloud';
6
5
  import * as bitbucketServer from '@backstage/plugin-scaffolder-backend-module-bitbucket-server';
7
6
  import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
7
+ import * as _backstage_types from '@backstage/types';
8
8
  import { Config } from '@backstage/config';
9
9
 
10
10
  /**
@@ -18,16 +18,17 @@ declare function createPublishBitbucketAction(options: {
18
18
  config: Config;
19
19
  }): _backstage_plugin_scaffolder_node.TemplateAction<{
20
20
  repoUrl: string;
21
- description?: string | undefined;
22
- defaultBranch?: string | undefined;
23
- repoVisibility?: "private" | "public" | undefined;
24
- sourcePath?: string | undefined;
25
- enableLFS?: boolean | undefined;
26
- token?: string | undefined;
27
- gitCommitMessage?: string | undefined;
28
- gitAuthorName?: string | undefined;
29
- gitAuthorEmail?: string | undefined;
30
- }, _backstage_types.JsonObject>;
21
+ description?: string;
22
+ defaultBranch?: string;
23
+ repoVisibility?: "private" | "public";
24
+ sourcePath?: string;
25
+ enableLFS?: boolean;
26
+ token?: string;
27
+ gitCommitMessage?: string;
28
+ gitAuthorName?: string;
29
+ gitAuthorEmail?: string;
30
+ signCommit?: boolean;
31
+ }, _backstage_types.JsonObject, "v1">;
31
32
 
32
33
  /**
33
34
  * @public
@@ -43,9 +44,13 @@ declare const createBitbucketPipelinesRunAction: (options: {
43
44
  }) => _backstage_plugin_scaffolder_node.TemplateAction<{
44
45
  workspace: string;
45
46
  repo_slug: string;
46
- body?: object | undefined;
47
- token?: string | undefined;
48
- }, _backstage_types.JsonObject>;
47
+ body?: object;
48
+ token?: string;
49
+ }, {
50
+ buildNumber: number;
51
+ repoUrl: string;
52
+ pipelinesUrl: string;
53
+ }, "v1">;
49
54
  /**
50
55
  * @public
51
56
  * @deprecated use import from `@backstage/plugin-scaffolder-backend-module-bitbucket-server` instead
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend-module-bitbucket",
3
- "version": "0.3.8-next.1",
3
+ "version": "0.3.8",
4
4
  "description": "The bitbucket module for @backstage/plugin-scaffolder-backend",
5
5
  "backstage": {
6
6
  "role": "backend-plugin-module",
@@ -30,13 +30,6 @@
30
30
  },
31
31
  "main": "./dist/index.cjs.js",
32
32
  "types": "./dist/index.d.ts",
33
- "typesVersions": {
34
- "*": {
35
- "index": [
36
- "dist/index.d.ts"
37
- ]
38
- }
39
- },
40
33
  "files": [
41
34
  "dist"
42
35
  ],
@@ -50,20 +43,20 @@
50
43
  "test": "backstage-cli package test"
51
44
  },
52
45
  "dependencies": {
53
- "@backstage/backend-plugin-api": "1.2.1-next.1",
54
- "@backstage/config": "1.3.2",
55
- "@backstage/errors": "1.2.7",
56
- "@backstage/integration": "1.16.1",
57
- "@backstage/plugin-scaffolder-backend-module-bitbucket-cloud": "0.2.7-next.1",
58
- "@backstage/plugin-scaffolder-backend-module-bitbucket-server": "0.2.7-next.1",
59
- "@backstage/plugin-scaffolder-node": "0.7.1-next.1",
46
+ "@backstage/backend-plugin-api": "^1.2.1",
47
+ "@backstage/config": "^1.3.2",
48
+ "@backstage/errors": "^1.2.7",
49
+ "@backstage/integration": "^1.16.2",
50
+ "@backstage/plugin-scaffolder-backend-module-bitbucket-cloud": "^0.2.7",
51
+ "@backstage/plugin-scaffolder-backend-module-bitbucket-server": "^0.2.7",
52
+ "@backstage/plugin-scaffolder-node": "^0.8.0",
60
53
  "fs-extra": "^11.2.0",
61
54
  "yaml": "^2.0.0"
62
55
  },
63
56
  "devDependencies": {
64
- "@backstage/backend-test-utils": "1.3.1-next.1",
65
- "@backstage/cli": "0.30.1-next.0",
66
- "@backstage/plugin-scaffolder-node-test-utils": "0.1.20-next.1",
57
+ "@backstage/backend-test-utils": "^1.3.1",
58
+ "@backstage/cli": "^0.31.0",
59
+ "@backstage/plugin-scaffolder-node-test-utils": "^0.2.0",
67
60
  "msw": "^1.0.0"
68
61
  },
69
62
  "deprecated": true