@backstage/plugin-scaffolder-backend-module-bitbucket-server 0.2.1-next.1 → 0.2.1-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,367 @@
1
+ 'use strict';
2
+
3
+ var errors = require('@backstage/errors');
4
+ var integration = require('@backstage/integration');
5
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
6
+ var fetch = require('node-fetch');
7
+ var fs = require('fs-extra');
8
+ var bitbucketServerPullRequest_examples = require('./bitbucketServerPullRequest.examples.cjs.js');
9
+
10
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
11
+
12
+ var fetch__default = /*#__PURE__*/_interopDefaultCompat(fetch);
13
+ var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
14
+
15
+ const createPullRequest = async (opts) => {
16
+ const {
17
+ project,
18
+ repo,
19
+ title,
20
+ description,
21
+ toRef,
22
+ fromRef,
23
+ reviewers,
24
+ authorization,
25
+ apiBaseUrl
26
+ } = opts;
27
+ let response;
28
+ const data = {
29
+ method: "POST",
30
+ body: JSON.stringify({
31
+ title,
32
+ description,
33
+ state: "OPEN",
34
+ open: true,
35
+ closed: false,
36
+ locked: true,
37
+ toRef,
38
+ fromRef,
39
+ reviewers: reviewers?.map((reviewer) => ({ user: { name: reviewer } }))
40
+ }),
41
+ headers: {
42
+ Authorization: authorization,
43
+ "Content-Type": "application/json"
44
+ }
45
+ };
46
+ try {
47
+ response = await fetch__default.default(
48
+ `${apiBaseUrl}/projects/${encodeURIComponent(
49
+ project
50
+ )}/repos/${encodeURIComponent(repo)}/pull-requests`,
51
+ data
52
+ );
53
+ } catch (e) {
54
+ throw new Error(`Unable to create pull-reqeusts, ${e}`);
55
+ }
56
+ if (response.status !== 201) {
57
+ throw new Error(
58
+ `Unable to create pull requests, ${response.status} ${response.statusText}, ${await response.text()}`
59
+ );
60
+ }
61
+ const r = await response.json();
62
+ return `${r.links.self[0].href}`;
63
+ };
64
+ const findBranches = async (opts) => {
65
+ const { project, repo, branchName, authorization, apiBaseUrl } = opts;
66
+ let response;
67
+ const options = {
68
+ method: "GET",
69
+ headers: {
70
+ Authorization: authorization,
71
+ "Content-Type": "application/json"
72
+ }
73
+ };
74
+ try {
75
+ response = await fetch__default.default(
76
+ `${apiBaseUrl}/projects/${encodeURIComponent(
77
+ project
78
+ )}/repos/${encodeURIComponent(
79
+ repo
80
+ )}/branches?boostMatches=true&filterText=${encodeURIComponent(
81
+ branchName
82
+ )}`,
83
+ options
84
+ );
85
+ } catch (e) {
86
+ throw new Error(`Unable to get branches, ${e}`);
87
+ }
88
+ if (response.status !== 200) {
89
+ throw new Error(
90
+ `Unable to get branches, ${response.status} ${response.statusText}, ${await response.text()}`
91
+ );
92
+ }
93
+ const r = await response.json();
94
+ for (const object of r.values) {
95
+ if (object.displayId === branchName) {
96
+ return object;
97
+ }
98
+ }
99
+ return void 0;
100
+ };
101
+ const createBranch = async (opts) => {
102
+ const { project, repo, branchName, authorization, apiBaseUrl, startPoint } = opts;
103
+ let response;
104
+ const options = {
105
+ method: "POST",
106
+ body: JSON.stringify({
107
+ name: branchName,
108
+ startPoint
109
+ }),
110
+ headers: {
111
+ Authorization: authorization,
112
+ "Content-Type": "application/json"
113
+ }
114
+ };
115
+ try {
116
+ response = await fetch__default.default(
117
+ `${apiBaseUrl}/projects/${encodeURIComponent(
118
+ project
119
+ )}/repos/${encodeURIComponent(repo)}/branches`,
120
+ options
121
+ );
122
+ } catch (e) {
123
+ throw new Error(`Unable to create branch, ${e}`);
124
+ }
125
+ if (response.status !== 200) {
126
+ throw new Error(
127
+ `Unable to create branch, ${response.status} ${response.statusText}, ${await response.text()}`
128
+ );
129
+ }
130
+ return await response.json();
131
+ };
132
+ const getDefaultBranch = async (opts) => {
133
+ const { project, repo, authorization, apiBaseUrl } = opts;
134
+ let response;
135
+ const options = {
136
+ method: "GET",
137
+ headers: {
138
+ Authorization: authorization,
139
+ "Content-Type": "application/json"
140
+ }
141
+ };
142
+ try {
143
+ response = await fetch__default.default(
144
+ `${apiBaseUrl}/projects/${project}/repos/${repo}/default-branch`,
145
+ options
146
+ );
147
+ } catch (error) {
148
+ throw error;
149
+ }
150
+ const { displayId } = await response.json();
151
+ const defaultBranch = displayId;
152
+ if (!defaultBranch) {
153
+ throw new Error(`Could not fetch default branch for ${project}/${repo}`);
154
+ }
155
+ return defaultBranch;
156
+ };
157
+ const isApiBaseUrlHttps = (apiBaseUrl) => {
158
+ const url = new URL(apiBaseUrl);
159
+ return url.protocol === "https:";
160
+ };
161
+ function createPublishBitbucketServerPullRequestAction(options) {
162
+ const { integrations, config } = options;
163
+ return pluginScaffolderNode.createTemplateAction({
164
+ id: "publish:bitbucketServer:pull-request",
165
+ examples: bitbucketServerPullRequest_examples.examples,
166
+ schema: {
167
+ input: {
168
+ type: "object",
169
+ required: ["repoUrl", "title", "sourceBranch"],
170
+ properties: {
171
+ repoUrl: {
172
+ title: "Repository Location",
173
+ type: "string"
174
+ },
175
+ title: {
176
+ title: "Pull Request title",
177
+ type: "string",
178
+ description: "The title for the pull request"
179
+ },
180
+ description: {
181
+ title: "Pull Request Description",
182
+ type: "string",
183
+ description: "The description of the pull request"
184
+ },
185
+ targetBranch: {
186
+ title: "Target Branch",
187
+ type: "string",
188
+ description: `Branch of repository to apply changes to. The default value is 'master'`
189
+ },
190
+ sourceBranch: {
191
+ title: "Source Branch",
192
+ type: "string",
193
+ description: "Branch of repository to copy changes from"
194
+ },
195
+ reviewers: {
196
+ title: "Pull Request Reviewers",
197
+ type: "array",
198
+ items: {
199
+ type: "string"
200
+ },
201
+ description: "The usernames of reviewers that will be added to the pull request"
202
+ },
203
+ token: {
204
+ title: "Authorization Token",
205
+ type: "string",
206
+ description: "The token to use for authorization to BitBucket Server"
207
+ },
208
+ gitAuthorName: {
209
+ title: "Author Name",
210
+ type: "string",
211
+ description: `Sets the author name for the commit. The default value is 'Scaffolder'`
212
+ },
213
+ gitAuthorEmail: {
214
+ title: "Author Email",
215
+ type: "string",
216
+ description: `Sets the author email for the commit.`
217
+ }
218
+ }
219
+ },
220
+ output: {
221
+ type: "object",
222
+ properties: {
223
+ pullRequestUrl: {
224
+ title: "A URL to the pull request with the provider",
225
+ type: "string"
226
+ }
227
+ }
228
+ }
229
+ },
230
+ async handler(ctx) {
231
+ const {
232
+ repoUrl,
233
+ title,
234
+ description,
235
+ targetBranch,
236
+ sourceBranch,
237
+ reviewers,
238
+ gitAuthorName,
239
+ gitAuthorEmail
240
+ } = ctx.input;
241
+ const { project, repo, host } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
242
+ if (!project) {
243
+ throw new errors.InputError(
244
+ `Invalid URL provider was included in the repo URL to create ${ctx.input.repoUrl}, missing project`
245
+ );
246
+ }
247
+ const integrationConfig = integrations.bitbucketServer.byHost(host);
248
+ if (!integrationConfig) {
249
+ throw new errors.InputError(
250
+ `No matching integration configuration for host ${host}, please check your integrations config`
251
+ );
252
+ }
253
+ const token = ctx.input.token ?? integrationConfig.config.token;
254
+ const authConfig = {
255
+ ...integrationConfig.config,
256
+ ...{ token }
257
+ };
258
+ const reqOpts = integration.getBitbucketServerRequestOptions(authConfig);
259
+ const authorization = reqOpts.headers.Authorization;
260
+ if (!authorization) {
261
+ throw new Error(
262
+ `Authorization has not been provided for ${integrationConfig.config.host}. Please add either (a) a user login auth token, or (b) a token input from the template or (c) username + password to the integration config.`
263
+ );
264
+ }
265
+ const apiBaseUrl = integrationConfig.config.apiBaseUrl;
266
+ let finalTargetBranch = targetBranch;
267
+ if (!finalTargetBranch) {
268
+ finalTargetBranch = await getDefaultBranch({
269
+ project,
270
+ repo,
271
+ authorization,
272
+ apiBaseUrl
273
+ });
274
+ }
275
+ const toRef = await findBranches({
276
+ project,
277
+ repo,
278
+ branchName: finalTargetBranch,
279
+ authorization,
280
+ apiBaseUrl
281
+ });
282
+ let fromRef = await findBranches({
283
+ project,
284
+ repo,
285
+ branchName: sourceBranch,
286
+ authorization,
287
+ apiBaseUrl
288
+ });
289
+ if (!fromRef) {
290
+ ctx.logger.info(
291
+ `source branch not found -> creating branch named: ${sourceBranch} lastCommit: ${toRef.latestCommit}`
292
+ );
293
+ const latestCommit = toRef.latestCommit;
294
+ fromRef = await createBranch({
295
+ project,
296
+ repo,
297
+ branchName: sourceBranch,
298
+ authorization,
299
+ apiBaseUrl,
300
+ startPoint: latestCommit
301
+ });
302
+ const isHttps = isApiBaseUrlHttps(apiBaseUrl);
303
+ const remoteUrl = `${isHttps ? "https" : "http"}://${host}/scm/${project}/${repo}.git`;
304
+ const auth = authConfig.token ? {
305
+ token
306
+ } : {
307
+ username: authConfig.username,
308
+ password: authConfig.password
309
+ };
310
+ const gitAuthorInfo = {
311
+ name: gitAuthorName || config.getOptionalString("scaffolder.defaultAuthor.name"),
312
+ email: gitAuthorEmail || config.getOptionalString("scaffolder.defaultAuthor.email")
313
+ };
314
+ const tempDir = await ctx.createTemporaryDirectory();
315
+ const sourceDir = pluginScaffolderNode.getRepoSourceDirectory(ctx.workspacePath, void 0);
316
+ await pluginScaffolderNode.cloneRepo({
317
+ url: remoteUrl,
318
+ dir: tempDir,
319
+ auth,
320
+ logger: ctx.logger,
321
+ ref: sourceBranch
322
+ });
323
+ await pluginScaffolderNode.createBranch({
324
+ dir: tempDir,
325
+ auth,
326
+ logger: ctx.logger,
327
+ ref: sourceBranch
328
+ });
329
+ fs__default.default.cpSync(sourceDir, tempDir, {
330
+ recursive: true,
331
+ filter: (path) => {
332
+ return !(path.indexOf(".git") > -1);
333
+ }
334
+ });
335
+ await pluginScaffolderNode.addFiles({
336
+ dir: tempDir,
337
+ auth,
338
+ logger: ctx.logger,
339
+ filepath: "."
340
+ });
341
+ await pluginScaffolderNode.commitAndPushBranch({
342
+ dir: tempDir,
343
+ auth,
344
+ logger: ctx.logger,
345
+ commitMessage: description ?? config.getOptionalString("scaffolder.defaultCommitMessage") ?? "",
346
+ gitAuthorInfo,
347
+ branch: sourceBranch
348
+ });
349
+ }
350
+ const pullRequestUrl = await createPullRequest({
351
+ project,
352
+ repo,
353
+ title,
354
+ description,
355
+ toRef,
356
+ fromRef,
357
+ reviewers,
358
+ authorization,
359
+ apiBaseUrl
360
+ });
361
+ ctx.output("pullRequestUrl", pullRequestUrl);
362
+ }
363
+ });
364
+ }
365
+
366
+ exports.createPublishBitbucketServerPullRequestAction = createPublishBitbucketServerPullRequestAction;
367
+ //# sourceMappingURL=bitbucketServerPullRequest.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitbucketServerPullRequest.cjs.js","sources":["../../src/actions/bitbucketServerPullRequest.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 getBitbucketServerRequestOptions,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n getRepoSourceDirectory,\n commitAndPushBranch,\n addFiles,\n createBranch as createGitBranch,\n cloneRepo,\n parseRepoUrl,\n} from '@backstage/plugin-scaffolder-node';\nimport fetch, { RequestInit, Response } from 'node-fetch';\nimport { Config } from '@backstage/config';\nimport fs from 'fs-extra';\nimport { examples } from './bitbucketServerPullRequest.examples';\n\nconst createPullRequest = async (opts: {\n project: string;\n repo: string;\n title: string;\n description?: string;\n toRef: {\n id: string;\n displayId: string;\n type: string;\n latestCommit: string;\n latestChangeset: string;\n isDefault: boolean;\n };\n fromRef: {\n id: string;\n displayId: string;\n type: string;\n latestCommit: string;\n latestChangeset: string;\n isDefault: boolean;\n };\n reviewers?: string[];\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const {\n project,\n repo,\n title,\n description,\n toRef,\n fromRef,\n reviewers,\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 description: description,\n state: 'OPEN',\n open: true,\n closed: false,\n locked: true,\n toRef: toRef,\n fromRef: fromRef,\n reviewers: reviewers?.map(reviewer => ({ user: { name: reviewer } })),\n }),\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(\n `${apiBaseUrl}/projects/${encodeURIComponent(\n project,\n )}/repos/${encodeURIComponent(repo)}/pull-requests`,\n data,\n );\n } catch (e) {\n throw new Error(`Unable to create pull-reqeusts, ${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.self[0].href}`;\n};\nconst findBranches = async (opts: {\n project: string;\n repo: string;\n branchName: string;\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const { project, 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}/projects/${encodeURIComponent(\n project,\n )}/repos/${encodeURIComponent(\n repo,\n )}/branches?boostMatches=true&filterText=${encodeURIComponent(\n 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 for (const object of r.values) {\n if (object.displayId === branchName) {\n return object;\n }\n }\n\n return undefined;\n};\nconst createBranch = async (opts: {\n project: string;\n repo: string;\n branchName: string;\n authorization: string;\n apiBaseUrl: string;\n startPoint: string;\n}) => {\n const { project, repo, branchName, authorization, apiBaseUrl, startPoint } =\n opts;\n\n let response: Response;\n const options: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n name: branchName,\n startPoint,\n }),\n headers: {\n Authorization: authorization,\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(\n `${apiBaseUrl}/projects/${encodeURIComponent(\n project,\n )}/repos/${encodeURIComponent(repo)}/branches`,\n options,\n );\n } catch (e) {\n throw new Error(`Unable to create branch, ${e}`);\n }\n\n if (response.status !== 200) {\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};\nconst getDefaultBranch = async (opts: {\n project: string;\n repo: string;\n authorization: string;\n apiBaseUrl: string;\n}) => {\n const { project, 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}/projects/${project}/repos/${repo}/default-branch`,\n options,\n );\n } catch (error) {\n throw error;\n }\n\n const { displayId } = await response.json();\n const defaultBranch = displayId;\n if (!defaultBranch) {\n throw new Error(`Could not fetch default branch for ${project}/${repo}`);\n }\n return defaultBranch;\n};\nconst isApiBaseUrlHttps = (apiBaseUrl: string): boolean => {\n const url = new URL(apiBaseUrl);\n return url.protocol === 'https:';\n};\n/**\n * Creates a BitbucketServer Pull Request action.\n * @public\n */\nexport function createPublishBitbucketServerPullRequestAction(options: {\n integrations: ScmIntegrationRegistry;\n config: Config;\n}) {\n const { integrations, config } = options;\n\n return createTemplateAction<{\n repoUrl: string;\n title: string;\n description?: string;\n targetBranch?: string;\n sourceBranch: string;\n reviewers?: string[];\n token?: string;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n }>({\n id: 'publish:bitbucketServer:pull-request',\n examples,\n schema: {\n input: {\n type: 'object',\n required: ['repoUrl', 'title', 'sourceBranch'],\n properties: {\n repoUrl: {\n title: 'Repository Location',\n type: 'string',\n },\n title: {\n title: 'Pull Request title',\n type: 'string',\n description: 'The title for the pull request',\n },\n description: {\n title: 'Pull Request Description',\n type: 'string',\n description: 'The description of the pull request',\n },\n targetBranch: {\n title: 'Target Branch',\n type: 'string',\n description: `Branch of repository to apply changes to. The default value is 'master'`,\n },\n sourceBranch: {\n title: 'Source Branch',\n type: 'string',\n description: 'Branch of repository to copy changes from',\n },\n reviewers: {\n title: 'Pull Request Reviewers',\n type: 'array',\n items: {\n type: 'string',\n },\n description:\n 'The usernames of reviewers that will be added to the pull request',\n },\n token: {\n title: 'Authorization Token',\n type: 'string',\n description:\n 'The token to use for authorization to BitBucket Server',\n },\n gitAuthorName: {\n title: 'Author Name',\n type: 'string',\n description: `Sets the author name for the commit. The default value is 'Scaffolder'`,\n },\n gitAuthorEmail: {\n title: 'Author Email',\n type: 'string',\n description: `Sets the author email for the commit.`,\n },\n },\n },\n output: {\n type: 'object',\n properties: {\n pullRequestUrl: {\n title: 'A URL to the pull request with the provider',\n type: 'string',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n title,\n description,\n targetBranch,\n sourceBranch,\n reviewers,\n gitAuthorName,\n gitAuthorEmail,\n } = ctx.input;\n\n const { project, repo, host } = parseRepoUrl(repoUrl, integrations);\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.bitbucketServer.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 token = ctx.input.token ?? integrationConfig.config.token;\n\n const authConfig = {\n ...integrationConfig.config,\n ...{ token },\n };\n\n const reqOpts = getBitbucketServerRequestOptions(authConfig);\n const authorization = reqOpts.headers.Authorization;\n if (!authorization) {\n throw new Error(\n `Authorization has not been provided for ${integrationConfig.config.host}. Please add either (a) a user login auth token, or (b) a token input from the template or (c) username + password to the integration config.`,\n );\n }\n\n const apiBaseUrl = integrationConfig.config.apiBaseUrl;\n\n let finalTargetBranch = targetBranch;\n if (!finalTargetBranch) {\n finalTargetBranch = await getDefaultBranch({\n project,\n repo,\n authorization,\n apiBaseUrl,\n });\n }\n\n const toRef = await findBranches({\n project,\n repo,\n branchName: finalTargetBranch!,\n authorization,\n apiBaseUrl,\n });\n\n let fromRef = await findBranches({\n project,\n repo,\n branchName: sourceBranch,\n authorization,\n apiBaseUrl,\n });\n\n if (!fromRef) {\n // create branch\n ctx.logger.info(\n `source branch not found -> creating branch named: ${sourceBranch} lastCommit: ${toRef.latestCommit}`,\n );\n const latestCommit = toRef.latestCommit;\n\n fromRef = await createBranch({\n project,\n repo,\n branchName: sourceBranch,\n authorization,\n apiBaseUrl,\n startPoint: latestCommit,\n });\n\n const isHttps: boolean = isApiBaseUrlHttps(apiBaseUrl);\n const remoteUrl = `${\n isHttps ? 'https' : 'http'\n }://${host}/scm/${project}/${repo}.git`;\n\n const auth = authConfig.token\n ? {\n token: token!,\n }\n : {\n username: authConfig.username!,\n password: authConfig.password!,\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 await createGitBranch({\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: path => {\n return !(path.indexOf('.git') > -1);\n },\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 project,\n repo,\n title,\n description,\n toRef,\n fromRef,\n reviewers,\n authorization,\n apiBaseUrl,\n });\n\n ctx.output('pullRequestUrl', pullRequestUrl);\n },\n });\n}\n"],"names":["fetch","createTemplateAction","examples","parseRepoUrl","InputError","getBitbucketServerRequestOptions","getRepoSourceDirectory","cloneRepo","createGitBranch","fs","addFiles","commitAndPushBranch"],"mappings":";;;;;;;;;;;;;;AAmCA,MAAM,iBAAA,GAAoB,OAAO,IAwB3B,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,OAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,WAAA;AAAA,IACA,KAAA;AAAA,IACA,OAAA;AAAA,IACA,SAAA;AAAA,IACA,aAAA;AAAA,IACA,UAAA;AAAA,GACE,GAAA,IAAA,CAAA;AAEJ,EAAI,IAAA,QAAA,CAAA;AACJ,EAAA,MAAM,IAAoB,GAAA;AAAA,IACxB,MAAQ,EAAA,MAAA;AAAA,IACR,IAAA,EAAM,KAAK,SAAU,CAAA;AAAA,MACnB,KAAA;AAAA,MACA,WAAA;AAAA,MACA,KAAO,EAAA,MAAA;AAAA,MACP,IAAM,EAAA,IAAA;AAAA,MACN,MAAQ,EAAA,KAAA;AAAA,MACR,MAAQ,EAAA,IAAA;AAAA,MACR,KAAA;AAAA,MACA,OAAA;AAAA,MACA,SAAA,EAAW,SAAW,EAAA,GAAA,CAAI,CAAa,QAAA,MAAA,EAAE,MAAM,EAAE,IAAA,EAAM,QAAS,EAAA,EAAI,CAAA,CAAA;AAAA,KACrE,CAAA;AAAA,IACD,OAAS,EAAA;AAAA,MACP,aAAe,EAAA,aAAA;AAAA,MACf,cAAgB,EAAA,kBAAA;AAAA,KAClB;AAAA,GACF,CAAA;AAEA,EAAI,IAAA;AACF,IAAA,QAAA,GAAW,MAAMA,sBAAA;AAAA,MACf,CAAA,EAAG,UA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EAAA,OAAA;AAAA,UACL,IAAA;AAAA,UACA,QAAQ,GAAI,CAAA,MAAA;AAAA,UACZ,aACE,EAAA,WAAA,IACA,MAAO,CAAA,iBAAA,CAAkB,iCAAiC,CAC1D,IAAA,EAAA;AAAA,UACF,aAAA;AAAA,UACA,MAAQ,EAAA,YAAA;AAAA,SACT,CAAA,CAAA;AAAA,OACH;AAEA,MAAM,MAAA,cAAA,GAAiB,MAAM,iBAAkB,CAAA;AAAA,QAC7C,OAAA;AAAA,QACA,IAAA;AAAA,QACA,KAAA;AAAA,QACA,WAAA;AAAA,QACA,KAAA;AAAA,QACA,OAAA;AAAA,QACA,SAAA;AAAA,QACA,aAAA;AAAA,QACA,UAAA;AAAA,OACD,CAAA,CAAA;AAED,MAAI,GAAA,CAAA,MAAA,CAAO,kBAAkB,cAAc,CAAA,CAAA;AAAA,KAC7C;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
@@ -0,0 +1,107 @@
1
+ 'use strict';
2
+
3
+ var yaml = require('yaml');
4
+
5
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
6
+
7
+ var yaml__default = /*#__PURE__*/_interopDefaultCompat(yaml);
8
+
9
+ const examples = [
10
+ {
11
+ description: "Creating pull request on bitbucket server with required fields",
12
+ example: yaml__default.default.stringify({
13
+ steps: [
14
+ {
15
+ action: "publish:bitbucketServer:pull-request",
16
+ id: "publish-bitbucket-server-pull-request-minimal",
17
+ name: "Creating pull request on bitbucket server",
18
+ input: {
19
+ repoUrl: "hosted.bitbucket.com?project=project&repo=repo",
20
+ title: "My pull request",
21
+ sourceBranch: "my-feature-branch"
22
+ }
23
+ }
24
+ ]
25
+ })
26
+ },
27
+ {
28
+ description: "Creating pull request on bitbucket server with custom descriptions",
29
+ example: yaml__default.default.stringify({
30
+ steps: [
31
+ {
32
+ action: "publish:bitbucketServer:pull-request",
33
+ id: "publish-bitbucket-server-pull-request-minimal",
34
+ name: "Creating pull request on bitbucket server",
35
+ input: {
36
+ repoUrl: "hosted.bitbucket.com?project=project&repo=repo",
37
+ title: "My pull request",
38
+ sourceBranch: "my-feature-branch",
39
+ description: "This is a detailed description of my pull request"
40
+ }
41
+ }
42
+ ]
43
+ })
44
+ },
45
+ {
46
+ description: "Creating pull request on bitbucket server with different target branch",
47
+ example: yaml__default.default.stringify({
48
+ steps: [
49
+ {
50
+ action: "publish:bitbucketServer:pull-request",
51
+ id: "publish-bitbucket-server-pull-request-target-branch",
52
+ name: "Creating pull request on bitbucket server",
53
+ input: {
54
+ repoUrl: "hosted.bitbucket.com?project=project&repo=repo",
55
+ title: "My pull request",
56
+ sourceBranch: "my-feature-branch",
57
+ targetBranch: "development"
58
+ }
59
+ }
60
+ ]
61
+ })
62
+ },
63
+ {
64
+ description: "Creating pull request on bitbucket server with authorization token",
65
+ example: yaml__default.default.stringify({
66
+ steps: [
67
+ {
68
+ action: "publish:bitbucketServer:pull-request",
69
+ id: "publish-bitbucket-server-pull-request-minimal",
70
+ name: "Creating pull request on bitbucket server",
71
+ input: {
72
+ repoUrl: "no-credentials.bitbucket.com?project=project&repo=repo",
73
+ title: "My pull request",
74
+ sourceBranch: "my-feature-branch",
75
+ token: "my-auth-token"
76
+ }
77
+ }
78
+ ]
79
+ })
80
+ },
81
+ {
82
+ description: "Creating pull request on bitbucket server with all fields",
83
+ example: yaml__default.default.stringify({
84
+ steps: [
85
+ {
86
+ action: "publish:bitbucketServer:pull-request",
87
+ id: "publish-bitbucket-server-pull-request-minimal",
88
+ name: "Creating pull request on bitbucket server",
89
+ input: {
90
+ repoUrl: "no-credentials.bitbucket.com?project=project&repo=repo",
91
+ title: "My pull request",
92
+ sourceBranch: "my-feature-branch",
93
+ targetBranch: "development",
94
+ description: "This is a detailed description of my pull request",
95
+ reviewers: ["reviewer1", "reviewer2"],
96
+ token: "my-auth-token",
97
+ gitAuthorName: "test-user",
98
+ gitAuthorEmail: "test-user@sample.com"
99
+ }
100
+ }
101
+ ]
102
+ })
103
+ }
104
+ ];
105
+
106
+ exports.examples = examples;
107
+ //# sourceMappingURL=bitbucketServerPullRequest.examples.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitbucketServerPullRequest.examples.cjs.js","sources":["../../src/actions/bitbucketServerPullRequest.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 'Creating pull request on bitbucket server with required fields',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketServer:pull-request',\n id: 'publish-bitbucket-server-pull-request-minimal',\n name: 'Creating pull request on bitbucket server',\n input: {\n repoUrl: 'hosted.bitbucket.com?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 server with custom descriptions',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketServer:pull-request',\n id: 'publish-bitbucket-server-pull-request-minimal',\n name: 'Creating pull request on bitbucket server',\n input: {\n repoUrl: 'hosted.bitbucket.com?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 server with different target branch',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketServer:pull-request',\n id: 'publish-bitbucket-server-pull-request-target-branch',\n name: 'Creating pull request on bitbucket server',\n input: {\n repoUrl: 'hosted.bitbucket.com?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 server with authorization token',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketServer:pull-request',\n id: 'publish-bitbucket-server-pull-request-minimal',\n name: 'Creating pull request on bitbucket server',\n input: {\n repoUrl: 'no-credentials.bitbucket.com?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 server with all fields',\n example: yaml.stringify({\n steps: [\n {\n action: 'publish:bitbucketServer:pull-request',\n id: 'publish-bitbucket-server-pull-request-minimal',\n name: 'Creating pull request on bitbucket server',\n input: {\n repoUrl: 'no-credentials.bitbucket.com?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 reviewers: ['reviewer1', 'reviewer2'],\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,gEAAA;AAAA,IACF,OAAA,EAASA,sBAAK,SAAU,CAAA;AAAA,MACtB,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAQ,EAAA,sCAAA;AAAA,UACR,EAAI,EAAA,+CAAA;AAAA,UACJ,IAAM,EAAA,2CAAA;AAAA,UACN,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,gDAAA;AAAA,YACT,KAAO,EAAA,iBAAA;AAAA,YACP,YAAc,EAAA,mBAAA;AAAA,WAChB;AAAA,SACF;AAAA,OACF;AAAA,KACD,CAAA;AAAA,GACH;AAAA,EACA;AAAA,IACE,WACE,EAAA,oEAAA;AAAA,IACF,OAAA,EAASA,sB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