@backstage/plugin-scaffolder-backend-module-github 0.5.1-next.0 → 0.5.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.
- package/CHANGELOG.md +43 -0
- package/dist/actions/gitHelpers.cjs.js +90 -0
- package/dist/actions/gitHelpers.cjs.js.map +1 -0
- package/dist/actions/gitHubEnvironment.examples.cjs.js +340 -0
- package/dist/actions/gitHubEnvironment.examples.cjs.js.map +1 -0
- package/dist/actions/github.cjs.js +187 -0
- package/dist/actions/github.cjs.js.map +1 -0
- package/dist/actions/github.examples.cjs.js +60 -0
- package/dist/actions/github.examples.cjs.js.map +1 -0
- package/dist/actions/githubActionsDispatch.cjs.js +84 -0
- package/dist/actions/githubActionsDispatch.cjs.js.map +1 -0
- package/dist/actions/githubActionsDispatch.examples.cjs.js +66 -0
- package/dist/actions/githubActionsDispatch.examples.cjs.js.map +1 -0
- package/dist/actions/githubAutolinks.cjs.js +76 -0
- package/dist/actions/githubAutolinks.cjs.js.map +1 -0
- package/dist/actions/githubAutolinks.examples.cjs.js +30 -0
- package/dist/actions/githubAutolinks.examples.cjs.js.map +1 -0
- package/dist/actions/githubBranchProtection.cjs.js +97 -0
- package/dist/actions/githubBranchProtection.cjs.js.map +1 -0
- package/dist/actions/githubBranchProtection.examples.cjs.js +62 -0
- package/dist/actions/githubBranchProtection.examples.cjs.js.map +1 -0
- package/dist/actions/githubDeployKey.cjs.js +123 -0
- package/dist/actions/githubDeployKey.cjs.js.map +1 -0
- package/dist/actions/githubDeployKey.examples.cjs.js +30 -0
- package/dist/actions/githubDeployKey.examples.cjs.js.map +1 -0
- package/dist/actions/githubEnvironment.cjs.js +255 -0
- package/dist/actions/githubEnvironment.cjs.js.map +1 -0
- package/dist/actions/githubIssuesLabel.cjs.js +79 -0
- package/dist/actions/githubIssuesLabel.cjs.js.map +1 -0
- package/dist/actions/githubIssuesLabel.examples.cjs.js +46 -0
- package/dist/actions/githubIssuesLabel.examples.cjs.js.map +1 -0
- package/dist/actions/githubPagesEnable.cjs.js +88 -0
- package/dist/actions/githubPagesEnable.cjs.js.map +1 -0
- package/dist/actions/githubPagesEnable.examples.cjs.js +224 -0
- package/dist/actions/githubPagesEnable.examples.cjs.js.map +1 -0
- package/dist/actions/githubPullRequest.cjs.js +336 -0
- package/dist/actions/githubPullRequest.cjs.js.map +1 -0
- package/dist/actions/githubPullRequest.examples.cjs.js +260 -0
- package/dist/actions/githubPullRequest.examples.cjs.js.map +1 -0
- package/dist/actions/githubRepoCreate.cjs.js +130 -0
- package/dist/actions/githubRepoCreate.cjs.js.map +1 -0
- package/dist/actions/githubRepoCreate.examples.cjs.js +964 -0
- package/dist/actions/githubRepoCreate.examples.cjs.js.map +1 -0
- package/dist/actions/githubRepoPush.cjs.js +122 -0
- package/dist/actions/githubRepoPush.cjs.js.map +1 -0
- package/dist/actions/githubRepoPush.examples.cjs.js +57 -0
- package/dist/actions/githubRepoPush.examples.cjs.js.map +1 -0
- package/dist/actions/githubWebhook.cjs.js +135 -0
- package/dist/actions/githubWebhook.cjs.js.map +1 -0
- package/dist/actions/githubWebhook.examples.cjs.js +113 -0
- package/dist/actions/githubWebhook.examples.cjs.js.map +1 -0
- package/dist/actions/helpers.cjs.js +292 -0
- package/dist/actions/helpers.cjs.js.map +1 -0
- package/dist/actions/inputProperties.cjs.js +319 -0
- package/dist/actions/inputProperties.cjs.js.map +1 -0
- package/dist/actions/outputProperties.cjs.js +19 -0
- package/dist/actions/outputProperties.cjs.js.map +1 -0
- package/dist/index.cjs.js +31 -4306
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +33 -1
- package/dist/module.cjs.js +92 -0
- package/dist/module.cjs.js.map +1 -0
- package/package.json +11 -11
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('path');
|
|
4
|
+
var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
|
|
5
|
+
var octokit = require('octokit');
|
|
6
|
+
var errors = require('@backstage/errors');
|
|
7
|
+
var octokitPluginCreatePullRequest = require('octokit-plugin-create-pull-request');
|
|
8
|
+
var helpers = require('./helpers.cjs.js');
|
|
9
|
+
var githubPullRequest_examples = require('./githubPullRequest.examples.cjs.js');
|
|
10
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
13
|
+
|
|
14
|
+
var path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
15
|
+
|
|
16
|
+
class GithubResponseError extends errors.CustomErrorBase {
|
|
17
|
+
}
|
|
18
|
+
const defaultClientFactory = async ({
|
|
19
|
+
integrations,
|
|
20
|
+
githubCredentialsProvider,
|
|
21
|
+
owner,
|
|
22
|
+
repo,
|
|
23
|
+
host = "github.com",
|
|
24
|
+
token: providedToken
|
|
25
|
+
}) => {
|
|
26
|
+
const [encodedHost, encodedOwner, encodedRepo] = [host, owner, repo].map(
|
|
27
|
+
encodeURIComponent
|
|
28
|
+
);
|
|
29
|
+
const octokitOptions = await helpers.getOctokitOptions({
|
|
30
|
+
integrations,
|
|
31
|
+
credentialsProvider: githubCredentialsProvider,
|
|
32
|
+
repoUrl: `${encodedHost}?owner=${encodedOwner}&repo=${encodedRepo}`,
|
|
33
|
+
token: providedToken
|
|
34
|
+
});
|
|
35
|
+
const OctokitPR = octokit.Octokit.plugin(octokitPluginCreatePullRequest.createPullRequest);
|
|
36
|
+
return new OctokitPR({
|
|
37
|
+
...octokitOptions,
|
|
38
|
+
...{ throttle: { enabled: false } }
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const createPublishGithubPullRequestAction = (options) => {
|
|
42
|
+
const {
|
|
43
|
+
integrations,
|
|
44
|
+
githubCredentialsProvider,
|
|
45
|
+
clientFactory = defaultClientFactory,
|
|
46
|
+
config
|
|
47
|
+
} = options;
|
|
48
|
+
return pluginScaffolderNode.createTemplateAction({
|
|
49
|
+
id: "publish:github:pull-request",
|
|
50
|
+
examples: githubPullRequest_examples.examples,
|
|
51
|
+
supportsDryRun: true,
|
|
52
|
+
schema: {
|
|
53
|
+
input: {
|
|
54
|
+
required: ["repoUrl", "title", "description", "branchName"],
|
|
55
|
+
type: "object",
|
|
56
|
+
properties: {
|
|
57
|
+
repoUrl: {
|
|
58
|
+
title: "Repository Location",
|
|
59
|
+
description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the repository name and 'owner' is an organization or username`,
|
|
60
|
+
type: "string"
|
|
61
|
+
},
|
|
62
|
+
branchName: {
|
|
63
|
+
type: "string",
|
|
64
|
+
title: "Branch Name",
|
|
65
|
+
description: "The name for the branch"
|
|
66
|
+
},
|
|
67
|
+
targetBranchName: {
|
|
68
|
+
type: "string",
|
|
69
|
+
title: "Target Branch Name",
|
|
70
|
+
description: "The target branch name of the merge request"
|
|
71
|
+
},
|
|
72
|
+
title: {
|
|
73
|
+
type: "string",
|
|
74
|
+
title: "Pull Request Name",
|
|
75
|
+
description: "The name for the pull request"
|
|
76
|
+
},
|
|
77
|
+
description: {
|
|
78
|
+
type: "string",
|
|
79
|
+
title: "Pull Request Description",
|
|
80
|
+
description: "The description of the pull request"
|
|
81
|
+
},
|
|
82
|
+
draft: {
|
|
83
|
+
type: "boolean",
|
|
84
|
+
title: "Create as Draft",
|
|
85
|
+
description: "Create a draft pull request"
|
|
86
|
+
},
|
|
87
|
+
sourcePath: {
|
|
88
|
+
type: "string",
|
|
89
|
+
title: "Working Subdirectory",
|
|
90
|
+
description: "Subdirectory of working directory to copy changes from"
|
|
91
|
+
},
|
|
92
|
+
targetPath: {
|
|
93
|
+
type: "string",
|
|
94
|
+
title: "Repository Subdirectory",
|
|
95
|
+
description: "Subdirectory of repository to apply changes to"
|
|
96
|
+
},
|
|
97
|
+
token: {
|
|
98
|
+
title: "Authentication Token",
|
|
99
|
+
type: "string",
|
|
100
|
+
description: "The token to use for authorization to GitHub"
|
|
101
|
+
},
|
|
102
|
+
reviewers: {
|
|
103
|
+
title: "Pull Request Reviewers",
|
|
104
|
+
type: "array",
|
|
105
|
+
items: {
|
|
106
|
+
type: "string"
|
|
107
|
+
},
|
|
108
|
+
description: "The users that will be added as reviewers to the pull request"
|
|
109
|
+
},
|
|
110
|
+
teamReviewers: {
|
|
111
|
+
title: "Pull Request Team Reviewers",
|
|
112
|
+
type: "array",
|
|
113
|
+
items: {
|
|
114
|
+
type: "string"
|
|
115
|
+
},
|
|
116
|
+
description: "The teams that will be added as reviewers to the pull request"
|
|
117
|
+
},
|
|
118
|
+
commitMessage: {
|
|
119
|
+
type: "string",
|
|
120
|
+
title: "Commit Message",
|
|
121
|
+
description: "The commit message for the pull request commit"
|
|
122
|
+
},
|
|
123
|
+
update: {
|
|
124
|
+
type: "boolean",
|
|
125
|
+
title: "Update",
|
|
126
|
+
description: "Update pull request if already exists"
|
|
127
|
+
},
|
|
128
|
+
forceFork: {
|
|
129
|
+
type: "boolean",
|
|
130
|
+
title: "Force Fork",
|
|
131
|
+
description: "Create pull request from a fork"
|
|
132
|
+
},
|
|
133
|
+
gitAuthorName: {
|
|
134
|
+
type: "string",
|
|
135
|
+
title: "Default Author Name",
|
|
136
|
+
description: "Sets the default author name for the commit. The default value is the authenticated user or 'Scaffolder'"
|
|
137
|
+
},
|
|
138
|
+
gitAuthorEmail: {
|
|
139
|
+
type: "string",
|
|
140
|
+
title: "Default Author Email",
|
|
141
|
+
description: "Sets the default author email for the commit. The default value is the authenticated user or 'scaffolder@backstage.io'"
|
|
142
|
+
},
|
|
143
|
+
forceEmptyGitAuthor: {
|
|
144
|
+
type: "boolean",
|
|
145
|
+
title: "Force Empty Git Author",
|
|
146
|
+
description: "Forces the author to be empty. This is useful when using a Github App, it permit the commit to be verified on Github"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
output: {
|
|
151
|
+
required: ["remoteUrl"],
|
|
152
|
+
type: "object",
|
|
153
|
+
properties: {
|
|
154
|
+
targetBranchName: {
|
|
155
|
+
title: "Target branch name of the merge request",
|
|
156
|
+
type: "string"
|
|
157
|
+
},
|
|
158
|
+
remoteUrl: {
|
|
159
|
+
type: "string",
|
|
160
|
+
title: "Pull Request URL",
|
|
161
|
+
description: "Link to the pull request in Github"
|
|
162
|
+
},
|
|
163
|
+
pullRequestNumber: {
|
|
164
|
+
type: "number",
|
|
165
|
+
title: "Pull Request Number",
|
|
166
|
+
description: "The pull request number"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
async handler(ctx) {
|
|
172
|
+
const {
|
|
173
|
+
repoUrl,
|
|
174
|
+
branchName,
|
|
175
|
+
targetBranchName,
|
|
176
|
+
title,
|
|
177
|
+
description,
|
|
178
|
+
draft,
|
|
179
|
+
targetPath,
|
|
180
|
+
sourcePath,
|
|
181
|
+
token: providedToken,
|
|
182
|
+
reviewers,
|
|
183
|
+
teamReviewers,
|
|
184
|
+
commitMessage,
|
|
185
|
+
update,
|
|
186
|
+
forceFork,
|
|
187
|
+
gitAuthorEmail,
|
|
188
|
+
gitAuthorName,
|
|
189
|
+
forceEmptyGitAuthor
|
|
190
|
+
} = ctx.input;
|
|
191
|
+
const { owner, repo, host } = pluginScaffolderNode.parseRepoUrl(repoUrl, integrations);
|
|
192
|
+
if (!owner) {
|
|
193
|
+
throw new errors.InputError(
|
|
194
|
+
`No owner provided for host: ${host}, and repo ${repo}`
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
const client = await clientFactory({
|
|
198
|
+
integrations,
|
|
199
|
+
githubCredentialsProvider,
|
|
200
|
+
host,
|
|
201
|
+
owner,
|
|
202
|
+
repo,
|
|
203
|
+
token: providedToken
|
|
204
|
+
});
|
|
205
|
+
const fileRoot = sourcePath ? backendPluginApi.resolveSafeChildPath(ctx.workspacePath, sourcePath) : ctx.workspacePath;
|
|
206
|
+
const directoryContents = await pluginScaffolderNode.serializeDirectoryContents(fileRoot, {
|
|
207
|
+
gitignore: true
|
|
208
|
+
});
|
|
209
|
+
const determineFileMode = (file) => {
|
|
210
|
+
if (file.symlink) return "120000";
|
|
211
|
+
if (file.executable) return "100755";
|
|
212
|
+
return "100644";
|
|
213
|
+
};
|
|
214
|
+
const determineFileEncoding = (file) => file.symlink ? "utf-8" : "base64";
|
|
215
|
+
const files = Object.fromEntries(
|
|
216
|
+
directoryContents.map((file) => [
|
|
217
|
+
targetPath ? path__default.default.posix.join(targetPath, file.path) : file.path,
|
|
218
|
+
{
|
|
219
|
+
// See the properties of tree items
|
|
220
|
+
// in https://docs.github.com/en/rest/reference/git#trees
|
|
221
|
+
mode: determineFileMode(file),
|
|
222
|
+
// Always use base64 encoding where possible to avoid doubling a binary file in size
|
|
223
|
+
// due to interpreting a binary file as utf-8 and sending github
|
|
224
|
+
// the utf-8 encoded content. Symlinks are kept as utf-8 to avoid them
|
|
225
|
+
// being formatted as a series of scrambled characters
|
|
226
|
+
//
|
|
227
|
+
// For example, the original gradle-wrapper.jar is 57.8k in https://github.com/kennethzfeng/pull-request-test/pull/5/files.
|
|
228
|
+
// Its size could be doubled to 98.3K (See https://github.com/kennethzfeng/pull-request-test/pull/4/files)
|
|
229
|
+
encoding: determineFileEncoding(file),
|
|
230
|
+
content: file.content.toString(determineFileEncoding(file))
|
|
231
|
+
}
|
|
232
|
+
])
|
|
233
|
+
);
|
|
234
|
+
if (ctx.isDryRun) {
|
|
235
|
+
ctx.logger.info(`Performing dry run of creating pull request`);
|
|
236
|
+
ctx.output("targetBranchName", branchName);
|
|
237
|
+
ctx.output("remoteUrl", repoUrl);
|
|
238
|
+
ctx.output("pullRequestNumber", 43);
|
|
239
|
+
ctx.logger.info(`Dry run complete`);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
try {
|
|
243
|
+
const createOptions = {
|
|
244
|
+
owner,
|
|
245
|
+
repo,
|
|
246
|
+
title,
|
|
247
|
+
changes: [
|
|
248
|
+
{
|
|
249
|
+
files,
|
|
250
|
+
commit: commitMessage ?? config?.getOptionalString("scaffolder.defaultCommitMessage") ?? title
|
|
251
|
+
}
|
|
252
|
+
],
|
|
253
|
+
body: description,
|
|
254
|
+
head: branchName,
|
|
255
|
+
draft,
|
|
256
|
+
update,
|
|
257
|
+
forceFork
|
|
258
|
+
};
|
|
259
|
+
const gitAuthorInfo = {
|
|
260
|
+
name: gitAuthorName ?? config?.getOptionalString("scaffolder.defaultAuthor.name"),
|
|
261
|
+
email: gitAuthorEmail ?? config?.getOptionalString("scaffolder.defaultAuthor.email")
|
|
262
|
+
};
|
|
263
|
+
if (!forceEmptyGitAuthor) {
|
|
264
|
+
if (gitAuthorInfo.name || gitAuthorInfo.email) {
|
|
265
|
+
if (Array.isArray(createOptions.changes)) {
|
|
266
|
+
createOptions.changes = createOptions.changes.map((change) => ({
|
|
267
|
+
...change,
|
|
268
|
+
author: {
|
|
269
|
+
name: gitAuthorInfo.name || "Scaffolder",
|
|
270
|
+
email: gitAuthorInfo.email || "scaffolder@backstage.io"
|
|
271
|
+
}
|
|
272
|
+
}));
|
|
273
|
+
} else {
|
|
274
|
+
createOptions.changes = {
|
|
275
|
+
...createOptions.changes,
|
|
276
|
+
author: {
|
|
277
|
+
name: gitAuthorInfo.name || "Scaffolder",
|
|
278
|
+
email: gitAuthorInfo.email || "scaffolder@backstage.io"
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (targetBranchName) {
|
|
285
|
+
createOptions.base = targetBranchName;
|
|
286
|
+
}
|
|
287
|
+
const response = await client.createPullRequest(createOptions);
|
|
288
|
+
if (!response) {
|
|
289
|
+
throw new GithubResponseError("null response from Github");
|
|
290
|
+
}
|
|
291
|
+
const pullRequestNumber = response.data.number;
|
|
292
|
+
if (reviewers || teamReviewers) {
|
|
293
|
+
const pullRequest = { owner, repo, number: pullRequestNumber };
|
|
294
|
+
await requestReviewersOnPullRequest(
|
|
295
|
+
pullRequest,
|
|
296
|
+
reviewers,
|
|
297
|
+
teamReviewers,
|
|
298
|
+
client,
|
|
299
|
+
ctx.logger
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
const targetBranch = response.data.base.ref;
|
|
303
|
+
ctx.output("targetBranchName", targetBranch);
|
|
304
|
+
ctx.output("remoteUrl", response.data.html_url);
|
|
305
|
+
ctx.output("pullRequestNumber", pullRequestNumber);
|
|
306
|
+
} catch (e) {
|
|
307
|
+
throw new GithubResponseError("Pull request creation failed", e);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
async function requestReviewersOnPullRequest(pr, reviewers, teamReviewers, client, logger) {
|
|
312
|
+
try {
|
|
313
|
+
const result = await client.rest.pulls.requestReviewers({
|
|
314
|
+
owner: pr.owner,
|
|
315
|
+
repo: pr.repo,
|
|
316
|
+
pull_number: pr.number,
|
|
317
|
+
reviewers,
|
|
318
|
+
team_reviewers: teamReviewers ? [...new Set(teamReviewers)] : void 0
|
|
319
|
+
});
|
|
320
|
+
const addedUsers = result.data.requested_reviewers?.join(", ") ?? "";
|
|
321
|
+
const addedTeams = result.data.requested_teams?.join(", ") ?? "";
|
|
322
|
+
logger.info(
|
|
323
|
+
`Added users [${addedUsers}] and teams [${addedTeams}] as reviewers to Pull request ${pr.number}`
|
|
324
|
+
);
|
|
325
|
+
} catch (e) {
|
|
326
|
+
logger.error(
|
|
327
|
+
`Failure when adding reviewers to Pull request ${pr.number}`,
|
|
328
|
+
e
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
exports.createPublishGithubPullRequestAction = createPublishGithubPullRequestAction;
|
|
335
|
+
exports.defaultClientFactory = defaultClientFactory;
|
|
336
|
+
//# sourceMappingURL=githubPullRequest.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"githubPullRequest.cjs.js","sources":["../../src/actions/githubPullRequest.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 path from 'path';\nimport {\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport {\n createTemplateAction,\n parseRepoUrl,\n SerializedFile,\n serializeDirectoryContents,\n} from '@backstage/plugin-scaffolder-node';\nimport { Octokit } from 'octokit';\nimport { CustomErrorBase, InputError } from '@backstage/errors';\nimport { createPullRequest } from 'octokit-plugin-create-pull-request';\nimport { getOctokitOptions } from './helpers';\nimport { examples } from './githubPullRequest.examples';\nimport {\n LoggerService,\n resolveSafeChildPath,\n} from '@backstage/backend-plugin-api';\nimport { Config } from '@backstage/config';\n\nexport type Encoding = 'utf-8' | 'base64';\n\nclass GithubResponseError extends CustomErrorBase {}\n\nexport const defaultClientFactory: CreateGithubPullRequestActionOptions['clientFactory'] =\n async ({\n integrations,\n githubCredentialsProvider,\n owner,\n repo,\n host = 'github.com',\n token: providedToken,\n }) => {\n const [encodedHost, encodedOwner, encodedRepo] = [host, owner, repo].map(\n encodeURIComponent,\n );\n\n const octokitOptions = await getOctokitOptions({\n integrations,\n credentialsProvider: githubCredentialsProvider,\n repoUrl: `${encodedHost}?owner=${encodedOwner}&repo=${encodedRepo}`,\n token: providedToken,\n });\n\n const OctokitPR = Octokit.plugin(createPullRequest);\n return new OctokitPR({\n ...octokitOptions,\n ...{ throttle: { enabled: false } },\n });\n };\n\n/**\n * The options passed to {@link createPublishGithubPullRequestAction} method\n * @public\n */\nexport interface CreateGithubPullRequestActionOptions {\n /**\n * An instance of {@link @backstage/integration#ScmIntegrationRegistry} that will be used in the action.\n */\n integrations: ScmIntegrationRegistry;\n /**\n * An instance of {@link @backstage/integration#GithubCredentialsProvider} that will be used to get credentials for the action.\n */\n githubCredentialsProvider?: GithubCredentialsProvider;\n /**\n * A method to return the Octokit client with the Pull Request Plugin.\n */\n clientFactory?: (input: {\n integrations: ScmIntegrationRegistry;\n githubCredentialsProvider?: GithubCredentialsProvider;\n host: string;\n owner: string;\n repo: string;\n token?: string;\n }) => Promise<\n Octokit & {\n createPullRequest(options: createPullRequest.Options): Promise<{\n data: {\n html_url: string;\n number: number;\n base: {\n ref: string;\n };\n };\n } | null>;\n }\n >;\n /**\n * An instance of {@link @backstage/config#Config} that will be used in the action.\n */\n config?: Config;\n}\n\ntype GithubPullRequest = {\n owner: string;\n repo: string;\n number: number;\n};\n\n/**\n * Creates a Github Pull Request action.\n * @public\n */\nexport const createPublishGithubPullRequestAction = (\n options: CreateGithubPullRequestActionOptions,\n) => {\n const {\n integrations,\n githubCredentialsProvider,\n clientFactory = defaultClientFactory,\n config,\n } = options;\n\n return createTemplateAction<{\n title: string;\n branchName: string;\n targetBranchName?: string;\n description: string;\n repoUrl: string;\n draft?: boolean;\n targetPath?: string;\n sourcePath?: string;\n token?: string;\n reviewers?: string[];\n teamReviewers?: string[];\n commitMessage?: string;\n update?: boolean;\n forceFork?: boolean;\n gitAuthorName?: string;\n gitAuthorEmail?: string;\n forceEmptyGitAuthor?: boolean;\n }>({\n id: 'publish:github:pull-request',\n examples,\n supportsDryRun: true,\n schema: {\n input: {\n required: ['repoUrl', 'title', 'description', 'branchName'],\n type: 'object',\n properties: {\n repoUrl: {\n title: 'Repository Location',\n description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the repository name and 'owner' is an organization or username`,\n type: 'string',\n },\n branchName: {\n type: 'string',\n title: 'Branch Name',\n description: 'The name for the branch',\n },\n targetBranchName: {\n type: 'string',\n title: 'Target Branch Name',\n description: 'The target branch name of the merge request',\n },\n title: {\n type: 'string',\n title: 'Pull Request Name',\n description: 'The name for the pull request',\n },\n description: {\n type: 'string',\n title: 'Pull Request Description',\n description: 'The description of the pull request',\n },\n draft: {\n type: 'boolean',\n title: 'Create as Draft',\n description: 'Create a draft pull request',\n },\n sourcePath: {\n type: 'string',\n title: 'Working Subdirectory',\n description:\n 'Subdirectory of working directory to copy changes from',\n },\n targetPath: {\n type: 'string',\n title: 'Repository Subdirectory',\n description: 'Subdirectory of repository to apply changes to',\n },\n token: {\n title: 'Authentication Token',\n type: 'string',\n description: 'The token to use for authorization to GitHub',\n },\n reviewers: {\n title: 'Pull Request Reviewers',\n type: 'array',\n items: {\n type: 'string',\n },\n description:\n 'The users that will be added as reviewers to the pull request',\n },\n teamReviewers: {\n title: 'Pull Request Team Reviewers',\n type: 'array',\n items: {\n type: 'string',\n },\n description:\n 'The teams that will be added as reviewers to the pull request',\n },\n commitMessage: {\n type: 'string',\n title: 'Commit Message',\n description: 'The commit message for the pull request commit',\n },\n update: {\n type: 'boolean',\n title: 'Update',\n description: 'Update pull request if already exists',\n },\n forceFork: {\n type: 'boolean',\n title: 'Force Fork',\n description: 'Create pull request from a fork',\n },\n gitAuthorName: {\n type: 'string',\n title: 'Default Author Name',\n description:\n \"Sets the default author name for the commit. The default value is the authenticated user or 'Scaffolder'\",\n },\n gitAuthorEmail: {\n type: 'string',\n title: 'Default Author Email',\n description:\n \"Sets the default author email for the commit. The default value is the authenticated user or 'scaffolder@backstage.io'\",\n },\n forceEmptyGitAuthor: {\n type: 'boolean',\n title: 'Force Empty Git Author',\n description:\n 'Forces the author to be empty. This is useful when using a Github App, it permit the commit to be verified on Github',\n },\n },\n },\n output: {\n required: ['remoteUrl'],\n type: 'object',\n properties: {\n targetBranchName: {\n title: 'Target branch name of the merge request',\n type: 'string',\n },\n remoteUrl: {\n type: 'string',\n title: 'Pull Request URL',\n description: 'Link to the pull request in Github',\n },\n pullRequestNumber: {\n type: 'number',\n title: 'Pull Request Number',\n description: 'The pull request number',\n },\n },\n },\n },\n async handler(ctx) {\n const {\n repoUrl,\n branchName,\n targetBranchName,\n title,\n description,\n draft,\n targetPath,\n sourcePath,\n token: providedToken,\n reviewers,\n teamReviewers,\n commitMessage,\n update,\n forceFork,\n gitAuthorEmail,\n gitAuthorName,\n forceEmptyGitAuthor,\n } = ctx.input;\n\n const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);\n\n if (!owner) {\n throw new InputError(\n `No owner provided for host: ${host}, and repo ${repo}`,\n );\n }\n\n const client = await clientFactory({\n integrations,\n githubCredentialsProvider,\n host,\n owner,\n repo,\n token: providedToken,\n });\n\n const fileRoot = sourcePath\n ? resolveSafeChildPath(ctx.workspacePath, sourcePath)\n : ctx.workspacePath;\n\n const directoryContents = await serializeDirectoryContents(fileRoot, {\n gitignore: true,\n });\n\n const determineFileMode = (file: SerializedFile): string => {\n if (file.symlink) return '120000';\n if (file.executable) return '100755';\n return '100644';\n };\n\n const determineFileEncoding = (\n file: SerializedFile,\n ): 'utf-8' | 'base64' => (file.symlink ? 'utf-8' : 'base64');\n\n const files = Object.fromEntries(\n directoryContents.map(file => [\n targetPath ? path.posix.join(targetPath, file.path) : file.path,\n {\n // See the properties of tree items\n // in https://docs.github.com/en/rest/reference/git#trees\n mode: determineFileMode(file),\n // Always use base64 encoding where possible to avoid doubling a binary file in size\n // due to interpreting a binary file as utf-8 and sending github\n // the utf-8 encoded content. Symlinks are kept as utf-8 to avoid them\n // being formatted as a series of scrambled characters\n //\n // For example, the original gradle-wrapper.jar is 57.8k in https://github.com/kennethzfeng/pull-request-test/pull/5/files.\n // Its size could be doubled to 98.3K (See https://github.com/kennethzfeng/pull-request-test/pull/4/files)\n encoding: determineFileEncoding(file),\n content: file.content.toString(determineFileEncoding(file)),\n },\n ]),\n );\n\n // If this is a dry run, log and return\n if (ctx.isDryRun) {\n ctx.logger.info(`Performing dry run of creating pull request`);\n ctx.output('targetBranchName', branchName);\n ctx.output('remoteUrl', repoUrl);\n ctx.output('pullRequestNumber', 43);\n ctx.logger.info(`Dry run complete`);\n return;\n }\n\n try {\n const createOptions: createPullRequest.Options = {\n owner,\n repo,\n title,\n changes: [\n {\n files,\n commit:\n commitMessage ??\n config?.getOptionalString('scaffolder.defaultCommitMessage') ??\n title,\n },\n ],\n body: description,\n head: branchName,\n draft,\n update,\n forceFork,\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 if (!forceEmptyGitAuthor) {\n if (gitAuthorInfo.name || gitAuthorInfo.email) {\n if (Array.isArray(createOptions.changes)) {\n createOptions.changes = createOptions.changes.map(change => ({\n ...change,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n }));\n } else {\n createOptions.changes = {\n ...createOptions.changes,\n author: {\n name: gitAuthorInfo.name || 'Scaffolder',\n email: gitAuthorInfo.email || 'scaffolder@backstage.io',\n },\n };\n }\n }\n }\n\n if (targetBranchName) {\n createOptions.base = targetBranchName;\n }\n const response = await client.createPullRequest(createOptions);\n\n if (!response) {\n throw new GithubResponseError('null response from Github');\n }\n\n const pullRequestNumber = response.data.number;\n if (reviewers || teamReviewers) {\n const pullRequest = { owner, repo, number: pullRequestNumber };\n await requestReviewersOnPullRequest(\n pullRequest,\n reviewers,\n teamReviewers,\n client,\n ctx.logger,\n );\n }\n\n const targetBranch = response.data.base.ref;\n ctx.output('targetBranchName', targetBranch);\n ctx.output('remoteUrl', response.data.html_url);\n ctx.output('pullRequestNumber', pullRequestNumber);\n } catch (e) {\n throw new GithubResponseError('Pull request creation failed', e);\n }\n },\n });\n\n async function requestReviewersOnPullRequest(\n pr: GithubPullRequest,\n reviewers: string[] | undefined,\n teamReviewers: string[] | undefined,\n client: Octokit,\n logger: LoggerService,\n ) {\n try {\n const result = await client.rest.pulls.requestReviewers({\n owner: pr.owner,\n repo: pr.repo,\n pull_number: pr.number,\n reviewers,\n team_reviewers: teamReviewers ? [...new Set(teamReviewers)] : undefined,\n });\n const addedUsers = result.data.requested_reviewers?.join(', ') ?? '';\n const addedTeams = result.data.requested_teams?.join(', ') ?? '';\n logger.info(\n `Added users [${addedUsers}] and teams [${addedTeams}] as reviewers to Pull request ${pr.number}`,\n );\n } catch (e) {\n logger.error(\n `Failure when adding reviewers to Pull request ${pr.number}`,\n e,\n );\n }\n }\n};\n"],"names":["CustomErrorBase","getOctokitOptions","Octokit","createPullRequest","createTemplateAction","examples","parseRepoUrl","InputError","resolveSafeChildPath","serializeDirectoryContents","path"],"mappings":";;;;;;;;;;;;;;;AAwCA,MAAM,4BAA4BA,sBAAgB,CAAA;AAAC,CAAA;AAE5C,MAAM,uBACX,OAAO;AAAA,EACL,YAAA;AAAA,EACA,yBAAA;AAAA,EACA,KAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAO,GAAA,YAAA;AAAA,EACP,KAAO,EAAA,aAAA;AACT,CAAM,KAAA;AACJ,EAAM,MAAA,CAAC,aAAa,YAAc,EAAA,WAAW,IAAI,CAAC,IAAA,EAAM,KAAO,EAAA,IAAI,CAAE,CAAA,GAAA;AAAA,IACnE,kBAAA;AAAA,GACF,CAAA;AAEA,EAAM,MAAA,cAAA,GAAiB,MAAMC,yBAAkB,CAAA;AAAA,IAC7C,YAAA;AAAA,IACA,mBAAqB,EAAA,yBAAA;AAAA,IACrB,SAAS,CAAG,EAAA,WAAW,CAAU,OAAA,EAAA,YAAY,SAAS,WAAW,CAAA,CAAA;AAAA,IACjE,KAAO,EAAA,aAAA;AAAA,GACR,CAAA,CAAA;AAED,EAAM,MAAA,SAAA,GAAYC,eAAQ,CAAA,MAAA,CAAOC,gDAAiB,CAAA,CAAA;AAClD,EAAA,OAAO,IAAI,SAAU,CAAA;AAAA,IACnB,GAAG,cAAA;AAAA,IACH,GAAG,EAAE,QAAA,EAAU,EAAE,OAAA,EAAS,OAAQ,EAAA;AAAA,GACnC,CAAA,CAAA;AAC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CAAA,CAAA;AAAA,OACjG,CAAA;AAAA,aACO,CAAG,EAAA;AACV,MAAO,MAAA,CAAA,KAAA;AAAA,QACL,CAAA,8CAAA,EAAiD,GAAG,MAAM,CAAA,CAAA;AAAA,QAC1D,CAAA;AAAA,OACF,CAAA;AAAA,KACF;AAAA,GACF;AACF;;;;;"}
|
|
@@ -0,0 +1,260 @@
|
|
|
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: "Create a pull request",
|
|
12
|
+
example: yaml__default.default.stringify({
|
|
13
|
+
steps: [
|
|
14
|
+
{
|
|
15
|
+
action: "publish:github:pull-request",
|
|
16
|
+
name: "Create a pull reuqest",
|
|
17
|
+
input: {
|
|
18
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
19
|
+
branchName: "new-app",
|
|
20
|
+
title: "Create my new app",
|
|
21
|
+
description: "This PR is really good"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
})
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
description: "Create a pull request with target branch name",
|
|
29
|
+
example: yaml__default.default.stringify({
|
|
30
|
+
steps: [
|
|
31
|
+
{
|
|
32
|
+
action: "publish:github:pull-request",
|
|
33
|
+
name: "Create a pull reuqest with target branch name",
|
|
34
|
+
input: {
|
|
35
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
36
|
+
branchName: "new-app",
|
|
37
|
+
title: "Create my new app",
|
|
38
|
+
description: "This PR is really good",
|
|
39
|
+
targetBranchName: "test"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
})
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
description: "Create a pull request as draft",
|
|
47
|
+
example: yaml__default.default.stringify({
|
|
48
|
+
steps: [
|
|
49
|
+
{
|
|
50
|
+
action: "publish:github:pull-request",
|
|
51
|
+
name: "Create a pull reuqest as draft",
|
|
52
|
+
input: {
|
|
53
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
54
|
+
branchName: "new-app",
|
|
55
|
+
title: "Create my new app",
|
|
56
|
+
description: "This PR is really good",
|
|
57
|
+
draft: true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
})
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
description: "Create a pull request with target path",
|
|
65
|
+
example: yaml__default.default.stringify({
|
|
66
|
+
steps: [
|
|
67
|
+
{
|
|
68
|
+
action: "publish:github:pull-request",
|
|
69
|
+
name: "Create a pull reuqest with target path",
|
|
70
|
+
input: {
|
|
71
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
72
|
+
branchName: "new-app",
|
|
73
|
+
title: "Create my new app",
|
|
74
|
+
description: "This PR is really good",
|
|
75
|
+
targetPath: "targetPath"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
})
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
description: "Create a pull request with source path",
|
|
83
|
+
example: yaml__default.default.stringify({
|
|
84
|
+
steps: [
|
|
85
|
+
{
|
|
86
|
+
action: "publish:github:pull-request",
|
|
87
|
+
name: "Create a pull reuqest with source path",
|
|
88
|
+
input: {
|
|
89
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
90
|
+
branchName: "new-app",
|
|
91
|
+
title: "Create my new app",
|
|
92
|
+
description: "This PR is really good",
|
|
93
|
+
sourcePath: "source"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
})
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
description: "Create a pull request with token",
|
|
101
|
+
example: yaml__default.default.stringify({
|
|
102
|
+
steps: [
|
|
103
|
+
{
|
|
104
|
+
action: "publish:github:pull-request",
|
|
105
|
+
name: "Create a pull reuqest",
|
|
106
|
+
input: {
|
|
107
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
108
|
+
branchName: "new-app",
|
|
109
|
+
title: "Create my new app",
|
|
110
|
+
description: "This PR is really good",
|
|
111
|
+
token: "gph_YourGitHubToken"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
})
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
description: "Create a pull request with reviewers",
|
|
119
|
+
example: yaml__default.default.stringify({
|
|
120
|
+
steps: [
|
|
121
|
+
{
|
|
122
|
+
action: "publish:github:pull-request",
|
|
123
|
+
name: "Create a pull reuqest with reviewers",
|
|
124
|
+
input: {
|
|
125
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
126
|
+
branchName: "new-app",
|
|
127
|
+
title: "Create my new app",
|
|
128
|
+
description: "This PR is really good",
|
|
129
|
+
reviewers: ["foobar"]
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
})
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
description: "Create a pull request with team reviewers",
|
|
137
|
+
example: yaml__default.default.stringify({
|
|
138
|
+
steps: [
|
|
139
|
+
{
|
|
140
|
+
action: "publish:github:pull-request",
|
|
141
|
+
name: "Create a pull reuqest with team reviewers",
|
|
142
|
+
input: {
|
|
143
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
144
|
+
branchName: "new-app",
|
|
145
|
+
title: "Create my new app",
|
|
146
|
+
description: "This PR is really good",
|
|
147
|
+
teamReviewers: ["team-foo"]
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
})
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
description: "Create a pull request with commit message",
|
|
155
|
+
example: yaml__default.default.stringify({
|
|
156
|
+
steps: [
|
|
157
|
+
{
|
|
158
|
+
action: "publish:github:pull-request",
|
|
159
|
+
name: "Create a pull reuqest",
|
|
160
|
+
input: {
|
|
161
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
162
|
+
branchName: "new-app",
|
|
163
|
+
title: "Create my new app",
|
|
164
|
+
description: "This PR is really good",
|
|
165
|
+
commitMessage: "Custom commit message"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
})
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
description: "Create a pull request with a git author name and email",
|
|
173
|
+
example: yaml__default.default.stringify({
|
|
174
|
+
steps: [
|
|
175
|
+
{
|
|
176
|
+
action: "publish:github:pull-request",
|
|
177
|
+
name: "Create a pull reuqest",
|
|
178
|
+
input: {
|
|
179
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
180
|
+
branchName: "new-app",
|
|
181
|
+
title: "Create my new app",
|
|
182
|
+
description: "This PR is really good",
|
|
183
|
+
gitAuthorName: "Foo Bar",
|
|
184
|
+
gitAuthorEmail: "foo@bar.example"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
|
+
})
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
description: "Create a pull request with a git author name",
|
|
192
|
+
example: yaml__default.default.stringify({
|
|
193
|
+
steps: [
|
|
194
|
+
{
|
|
195
|
+
action: "publish:github:pull-request",
|
|
196
|
+
name: "Create a pull reuqest",
|
|
197
|
+
input: {
|
|
198
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
199
|
+
branchName: "new-app",
|
|
200
|
+
title: "Create my new app",
|
|
201
|
+
description: "This PR is really good",
|
|
202
|
+
// gitAuthorEmail will be 'scaffolder@backstage.io'
|
|
203
|
+
// once one author attribute has been set we need to set both
|
|
204
|
+
gitAuthorName: "Foo Bar"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
})
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
description: "Create a pull request with a git author email",
|
|
212
|
+
example: yaml__default.default.stringify({
|
|
213
|
+
steps: [
|
|
214
|
+
{
|
|
215
|
+
action: "publish:github:pull-request",
|
|
216
|
+
name: "Create a pull reuqest",
|
|
217
|
+
input: {
|
|
218
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
219
|
+
branchName: "new-app",
|
|
220
|
+
title: "Create my new app",
|
|
221
|
+
description: "This PR is really good",
|
|
222
|
+
// gitAuthorName will be 'Scaffolder'
|
|
223
|
+
// once one author attribute has been set we need to set both
|
|
224
|
+
gitAuthorEmail: "foo@bar.example"
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
]
|
|
228
|
+
})
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
description: "Create a pull request with all parameters",
|
|
232
|
+
example: yaml__default.default.stringify({
|
|
233
|
+
steps: [
|
|
234
|
+
{
|
|
235
|
+
action: "publish:github:pull-request",
|
|
236
|
+
name: "Create a pull reuqest",
|
|
237
|
+
input: {
|
|
238
|
+
repoUrl: "github.com?repo=repo&owner=owner",
|
|
239
|
+
branchName: "new-app",
|
|
240
|
+
title: "Create my new app",
|
|
241
|
+
description: "This PR is really good",
|
|
242
|
+
targetBranchName: "test",
|
|
243
|
+
draft: true,
|
|
244
|
+
targetPath: "targetPath",
|
|
245
|
+
sourcePath: "source",
|
|
246
|
+
token: "gph_YourGitHubToken",
|
|
247
|
+
reviewers: ["foobar"],
|
|
248
|
+
teamReviewers: ["team-foo"],
|
|
249
|
+
commitMessage: "Commit for foo changes",
|
|
250
|
+
gitAuthorName: "Foo Bar",
|
|
251
|
+
gitAuthorEmail: "foo@bar.example"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
})
|
|
256
|
+
}
|
|
257
|
+
];
|
|
258
|
+
|
|
259
|
+
exports.examples = examples;
|
|
260
|
+
//# sourceMappingURL=githubPullRequest.examples.cjs.js.map
|