@backstage/plugin-scaffolder-backend 1.9.1-next.0 → 1.10.0-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 CHANGED
@@ -1,5 +1,116 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
+ ## 1.10.0-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 2fadff2a25: Change scaffolder task actions to include markdown to demonstrate the new `ActionsPage` markdown feature.
8
+ - b44eb68bcb: This patch adds changes to provide examples alongside scaffolder task actions.
9
+
10
+ The `createTemplateAction` function now takes a list of examples e.g.
11
+
12
+ ```typescript
13
+ const actionExamples = [
14
+ {
15
+ description: 'Example 1',
16
+ example: yaml.stringify({
17
+ steps: [
18
+ {
19
+ action: 'test:action',
20
+ id: 'test',
21
+ input: {
22
+ input1: 'value',
23
+ },
24
+ },
25
+ ],
26
+ }),
27
+ },
28
+ ];
29
+
30
+ export function createTestAction() {
31
+ return createTemplateAction({
32
+ id: 'test:action',
33
+ examples: [
34
+ {
35
+ description: 'Example 1',
36
+ examples: actionExamples
37
+ }
38
+ ],
39
+ ...,
40
+ });
41
+ ```
42
+
43
+ These examples can be retrieved later from the api.
44
+
45
+ ```bash
46
+ curl http://localhost:7007/api/scaffolder/v2/actions
47
+ ```
48
+
49
+ ```json
50
+ [
51
+ {
52
+ "id": "test:action",
53
+ "examples": [
54
+ {
55
+ "description": "Example 1",
56
+ "example": "steps:\n - action: test:action\n id: test\n input:\n input1: value\n"
57
+ }
58
+ ],
59
+ "schema": {
60
+ "input": {
61
+ "type": "object",
62
+ "properties": {
63
+ "input1": {
64
+ "title": "Input 1",
65
+ "type": "string"
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ ]
72
+ ```
73
+
74
+ - 8e06f3cf00: Switched imports of `loggerToWinstonLogger` to `@backstage/backend-common`.
75
+ - Updated dependencies
76
+ - @backstage/backend-plugin-api@0.3.0-next.1
77
+ - @backstage/backend-common@0.18.0-next.1
78
+ - @backstage/backend-tasks@0.4.1-next.1
79
+ - @backstage/catalog-client@1.3.0-next.2
80
+ - @backstage/plugin-catalog-backend@1.7.0-next.2
81
+ - @backstage/plugin-catalog-node@1.3.1-next.2
82
+ - @backstage/plugin-auth-node@0.2.9-next.1
83
+ - @backstage/catalog-model@1.1.5-next.1
84
+ - @backstage/config@1.0.6-next.0
85
+ - @backstage/errors@1.1.4
86
+ - @backstage/integration@1.4.2-next.0
87
+ - @backstage/types@1.0.2
88
+ - @backstage/plugin-scaffolder-common@1.2.4-next.1
89
+
90
+ ## 1.10.0-next.1
91
+
92
+ ### Minor Changes
93
+
94
+ - 04a2048fb8: Allow custom repository roles to be configured on github repos
95
+ - a69664faee: Add Github repository support for squash merge commit title and message options
96
+
97
+ ### Patch Changes
98
+
99
+ - Updated dependencies
100
+ - @backstage/backend-plugin-api@0.2.1-next.0
101
+ - @backstage/backend-common@0.18.0-next.0
102
+ - @backstage/config@1.0.6-next.0
103
+ - @backstage/plugin-catalog-backend@1.7.0-next.1
104
+ - @backstage/plugin-catalog-node@1.3.1-next.1
105
+ - @backstage/backend-tasks@0.4.1-next.0
106
+ - @backstage/catalog-client@1.3.0-next.1
107
+ - @backstage/catalog-model@1.1.5-next.1
108
+ - @backstage/errors@1.1.4
109
+ - @backstage/integration@1.4.2-next.0
110
+ - @backstage/types@1.0.2
111
+ - @backstage/plugin-auth-node@0.2.9-next.0
112
+ - @backstage/plugin-scaffolder-common@1.2.4-next.1
113
+
3
114
  ## 1.9.1-next.0
4
115
 
5
116
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend",
3
- "version": "1.9.1-next.0",
3
+ "version": "1.10.0-next.2",
4
4
  "main": "../dist/index.cjs.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -289,6 +289,8 @@ gitAuthorName?: string | undefined;
289
289
  gitAuthorEmail?: string | undefined;
290
290
  allowRebaseMerge?: boolean | undefined;
291
291
  allowSquashMerge?: boolean | undefined;
292
+ squashMergeCommitTitle?: "PR_TITLE" | "COMMIT_OR_PR_TITLE" | undefined;
293
+ squashMergeCommitMessage?: "PR_BODY" | "COMMIT_MESSAGES" | "BLANK" | undefined;
292
294
  allowMergeCommit?: boolean | undefined;
293
295
  allowAutoMerge?: boolean | undefined;
294
296
  requireCodeOwnerReviews?: boolean | undefined;
@@ -303,10 +305,10 @@ requiredConversationResolution?: boolean | undefined;
303
305
  repoVisibility?: "internal" | "private" | "public" | undefined;
304
306
  collaborators?: ({
305
307
  user: string;
306
- access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
308
+ access: string;
307
309
  } | {
308
310
  team: string;
309
- access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
311
+ access: string;
310
312
  } | {
311
313
  /** @deprecated This field is deprecated in favor of team */
312
314
  username: string;
@@ -505,6 +507,8 @@ gitAuthorName?: string | undefined;
505
507
  gitAuthorEmail?: string | undefined;
506
508
  allowRebaseMerge?: boolean | undefined;
507
509
  allowSquashMerge?: boolean | undefined;
510
+ squashMergeCommitTitle?: "PR_TITLE" | "COMMIT_OR_PR_TITLE" | undefined;
511
+ squashMergeCommitMessage?: "PR_BODY" | "COMMIT_MESSAGES" | "BLANK" | undefined;
508
512
  allowMergeCommit?: boolean | undefined;
509
513
  allowAutoMerge?: boolean | undefined;
510
514
  sourcePath?: string | undefined;
@@ -521,10 +525,10 @@ requiredConversationResolution?: boolean | undefined;
521
525
  repoVisibility?: "internal" | "private" | "public" | undefined;
522
526
  collaborators?: ({
523
527
  user: string;
524
- access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
528
+ access: string;
525
529
  } | {
526
530
  team: string;
527
- access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
531
+ access: string;
528
532
  } | {
529
533
  /** @deprecated This field is deprecated in favor of team */
530
534
  username: string;
@@ -1059,6 +1063,10 @@ export declare class TaskWorker {
1059
1063
  export declare type TemplateAction<Input extends JsonObject> = {
1060
1064
  id: string;
1061
1065
  description?: string;
1066
+ examples?: {
1067
+ description: string;
1068
+ example: string;
1069
+ }[];
1062
1070
  supportsDryRun?: boolean;
1063
1071
  schema?: {
1064
1072
  input?: Schema;
@@ -289,6 +289,8 @@ gitAuthorName?: string | undefined;
289
289
  gitAuthorEmail?: string | undefined;
290
290
  allowRebaseMerge?: boolean | undefined;
291
291
  allowSquashMerge?: boolean | undefined;
292
+ squashMergeCommitTitle?: "PR_TITLE" | "COMMIT_OR_PR_TITLE" | undefined;
293
+ squashMergeCommitMessage?: "PR_BODY" | "COMMIT_MESSAGES" | "BLANK" | undefined;
292
294
  allowMergeCommit?: boolean | undefined;
293
295
  allowAutoMerge?: boolean | undefined;
294
296
  requireCodeOwnerReviews?: boolean | undefined;
@@ -303,10 +305,10 @@ requiredConversationResolution?: boolean | undefined;
303
305
  repoVisibility?: "internal" | "private" | "public" | undefined;
304
306
  collaborators?: ({
305
307
  user: string;
306
- access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
308
+ access: string;
307
309
  } | {
308
310
  team: string;
309
- access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
311
+ access: string;
310
312
  } | {
311
313
  /** @deprecated This field is deprecated in favor of team */
312
314
  username: string;
@@ -505,6 +507,8 @@ gitAuthorName?: string | undefined;
505
507
  gitAuthorEmail?: string | undefined;
506
508
  allowRebaseMerge?: boolean | undefined;
507
509
  allowSquashMerge?: boolean | undefined;
510
+ squashMergeCommitTitle?: "PR_TITLE" | "COMMIT_OR_PR_TITLE" | undefined;
511
+ squashMergeCommitMessage?: "PR_BODY" | "COMMIT_MESSAGES" | "BLANK" | undefined;
508
512
  allowMergeCommit?: boolean | undefined;
509
513
  allowAutoMerge?: boolean | undefined;
510
514
  sourcePath?: string | undefined;
@@ -521,10 +525,10 @@ requiredConversationResolution?: boolean | undefined;
521
525
  repoVisibility?: "internal" | "private" | "public" | undefined;
522
526
  collaborators?: ({
523
527
  user: string;
524
- access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
528
+ access: string;
525
529
  } | {
526
530
  team: string;
527
- access: 'pull' | 'push' | 'admin' | 'maintain' | 'triage';
531
+ access: string;
528
532
  } | {
529
533
  /** @deprecated This field is deprecated in favor of team */
530
534
  username: string;
@@ -1041,6 +1045,10 @@ export declare class TaskWorker {
1041
1045
  export declare type TemplateAction<Input extends JsonObject> = {
1042
1046
  id: string;
1043
1047
  description?: string;
1048
+ examples?: {
1049
+ description: string;
1050
+ example: string;
1051
+ }[];
1044
1052
  supportsDryRun?: boolean;
1045
1053
  schema?: {
1046
1054
  input?: Schema;
package/dist/index.cjs.js CHANGED
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var errors = require('@backstage/errors');
6
6
  var catalogModel = require('@backstage/catalog-model');
7
- var fs = require('fs-extra');
8
7
  var yaml = require('yaml');
8
+ var fs = require('fs-extra');
9
9
  var backendCommon = require('@backstage/backend-common');
10
10
  var integration = require('@backstage/integration');
11
11
  var path = require('path');
@@ -62,8 +62,9 @@ function _interopNamespace(e) {
62
62
  return Object.freeze(n);
63
63
  }
64
64
 
65
- var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
65
+ var yaml__default = /*#__PURE__*/_interopDefaultLegacy(yaml);
66
66
  var yaml__namespace = /*#__PURE__*/_interopNamespace(yaml);
67
+ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
67
68
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
68
69
  var globby__default = /*#__PURE__*/_interopDefaultLegacy(globby);
69
70
  var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
@@ -81,11 +82,30 @@ const createTemplateAction = (templateAction) => {
81
82
  return templateAction;
82
83
  };
83
84
 
85
+ const id$2 = "catalog:register";
86
+ const examples$2 = [
87
+ {
88
+ description: "Register with the catalog",
89
+ example: yaml__default["default"].stringify({
90
+ steps: [
91
+ {
92
+ action: id$2,
93
+ id: "register-with-catalog",
94
+ name: "Register with the catalog",
95
+ input: {
96
+ catalogInfoUrl: "http://github.com/backstage/backstage/blob/master/catalog-info.yaml"
97
+ }
98
+ }
99
+ ]
100
+ })
101
+ }
102
+ ];
84
103
  function createCatalogRegisterAction(options) {
85
104
  const { catalogClient, integrations } = options;
86
105
  return createTemplateAction({
87
- id: "catalog:register",
106
+ id: id$2,
88
107
  description: "Registers entities from a catalog descriptor file in the workspace into the software catalog.",
108
+ examples: examples$2,
89
109
  schema: {
90
110
  input: {
91
111
  oneOf: [
@@ -203,10 +223,41 @@ function createCatalogRegisterAction(options) {
203
223
  });
204
224
  }
205
225
 
226
+ const id$1 = "catalog:write";
227
+ const examples$1 = [
228
+ {
229
+ description: "Write a catalog yaml file",
230
+ example: yaml__namespace.stringify({
231
+ steps: [
232
+ {
233
+ action: id$1,
234
+ id: "create-catalog-info-file",
235
+ name: "Create catalog file",
236
+ input: {
237
+ entity: {
238
+ apiVersion: "backstage.io/v1alpha1",
239
+ kind: "Component",
240
+ metadata: {
241
+ name: "test",
242
+ annotations: {}
243
+ },
244
+ spec: {
245
+ type: "service",
246
+ lifecycle: "production",
247
+ owner: "default/owner"
248
+ }
249
+ }
250
+ }
251
+ }
252
+ ]
253
+ })
254
+ }
255
+ ];
206
256
  function createCatalogWriteAction() {
207
257
  return createTemplateAction({
208
- id: "catalog:write",
258
+ id: id$1,
209
259
  description: "Writes the catalog-info.yaml for your template",
260
+ examples: examples$1,
210
261
  schema: {
211
262
  input: {
212
263
  type: "object",
@@ -237,10 +288,44 @@ function createCatalogWriteAction() {
237
288
  });
238
289
  }
239
290
 
291
+ const id = "debug:log";
292
+ const examples = [
293
+ {
294
+ description: "Write a debug message",
295
+ example: yaml__default["default"].stringify({
296
+ steps: [
297
+ {
298
+ action: id,
299
+ id: "write-debug-line",
300
+ name: 'Write "Hello Backstage!" log line',
301
+ input: {
302
+ message: "Hello Backstage!"
303
+ }
304
+ }
305
+ ]
306
+ })
307
+ },
308
+ {
309
+ description: "List the workspace directory",
310
+ example: yaml__default["default"].stringify({
311
+ steps: [
312
+ {
313
+ action: id,
314
+ id: "write-workspace-directory",
315
+ name: "List the workspace directory",
316
+ input: {
317
+ listWorkspace: true
318
+ }
319
+ }
320
+ ]
321
+ })
322
+ }
323
+ ];
240
324
  function createDebugLogAction() {
241
325
  return createTemplateAction({
242
- id: "debug:log",
326
+ id,
243
327
  description: "Writes a message into the log or lists all files in the workspace.",
328
+ examples,
244
329
  schema: {
245
330
  input: {
246
331
  type: "object",
@@ -327,7 +412,7 @@ function createFetchPlainAction(options) {
327
412
  const { reader, integrations } = options;
328
413
  return createTemplateAction({
329
414
  id: "fetch:plain",
330
- description: "Downloads content and places it in the workspace, or optionally in a subdirectory specified by the 'targetPath' input option.",
415
+ description: "Downloads content and places it in the workspace, or optionally in a subdirectory specified by the `targetPath` input option.",
331
416
  schema: {
332
417
  input: {
333
418
  type: "object",
@@ -512,7 +597,7 @@ function createFetchTemplateAction(options) {
512
597
  } = options;
513
598
  return createTemplateAction({
514
599
  id: "fetch:template",
515
- description: "Downloads a skeleton, templates variables into file and directory names and content, and places the result in the workspace, or optionally in a subdirectory specified by the 'targetPath' input option.",
600
+ description: "Downloads a skeleton, templates variables into file and directory names and content, and places the result in the workspace, or optionally in a subdirectory specified by the `targetPath` input option.",
516
601
  schema: {
517
602
  input: {
518
603
  type: "object",
@@ -1007,6 +1092,13 @@ const enableBranchProtectionOnDefaultRepoBranch = async ({
1007
1092
  try {
1008
1093
  await client.rest.repos.updateBranchProtection({
1009
1094
  mediaType: {
1095
+ /**
1096
+ * 👇 we need this preview because allowing a custom
1097
+ * reviewer count on branch protection is a preview
1098
+ * feature
1099
+ *
1100
+ * More here: https://docs.github.com/en/rest/overview/api-previews#require-multiple-approving-reviews
1101
+ */
1010
1102
  previews: ["luke-cage-preview"]
1011
1103
  },
1012
1104
  owner,
@@ -1056,6 +1148,7 @@ async function getOctokitOptions(options) {
1056
1148
  const { integrations, credentialsProvider, repoUrl, token } = options;
1057
1149
  const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);
1058
1150
  const requestOptions = {
1151
+ // set timeout to 60 seconds
1059
1152
  timeout: DEFAULT_TIMEOUT_MS
1060
1153
  };
1061
1154
  if (!owner) {
@@ -1090,7 +1183,7 @@ async function getOctokitOptions(options) {
1090
1183
  previews: ["nebula-preview"]
1091
1184
  };
1092
1185
  }
1093
- async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, repoVisibility, description, homepage, deleteBranchOnMerge, allowMergeCommit, allowSquashMerge, allowRebaseMerge, allowAutoMerge, access, collaborators, hasProjects, hasWiki, hasIssues, topics, logger) {
1186
+ async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, repoVisibility, description, homepage, deleteBranchOnMerge, allowMergeCommit, allowSquashMerge, squashMergeCommitTitle, squashMergeCommitMessage, allowRebaseMerge, allowAutoMerge, access, collaborators, hasProjects, hasWiki, hasIssues, topics, logger) {
1094
1187
  const user = await client.rest.users.getByUsername({
1095
1188
  username: owner
1096
1189
  });
@@ -1103,6 +1196,8 @@ async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, r
1103
1196
  delete_branch_on_merge: deleteBranchOnMerge,
1104
1197
  allow_merge_commit: allowMergeCommit,
1105
1198
  allow_squash_merge: allowSquashMerge,
1199
+ squash_merge_commit_title: squashMergeCommitTitle,
1200
+ squash_merge_commit_message: squashMergeCommitMessage,
1106
1201
  allow_rebase_merge: allowRebaseMerge,
1107
1202
  allow_auto_merge: allowAutoMerge,
1108
1203
  homepage,
@@ -1116,6 +1211,8 @@ async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, r
1116
1211
  delete_branch_on_merge: deleteBranchOnMerge,
1117
1212
  allow_merge_commit: allowMergeCommit,
1118
1213
  allow_squash_merge: allowSquashMerge,
1214
+ squash_merge_commit_title: squashMergeCommitTitle,
1215
+ squash_merge_commit_message: squashMergeCommitMessage,
1119
1216
  allow_rebase_merge: allowRebaseMerge,
1120
1217
  allow_auto_merge: allowAutoMerge,
1121
1218
  homepage,
@@ -1463,6 +1560,16 @@ const allowSquashMerge = {
1463
1560
  type: "boolean",
1464
1561
  description: `Allow squash merges. The default value is 'true'`
1465
1562
  };
1563
+ const squashMergeCommitTitle = {
1564
+ title: "Default squash merge commit title",
1565
+ enum: ["PR_TITLE", "COMMIT_OR_PR_TITLE"],
1566
+ description: `Sets the default value for a squash merge commit title. The default value is 'COMMIT_OR_PR_TITLE'`
1567
+ };
1568
+ const squashMergeCommitMessage = {
1569
+ title: "Default squash merge commit message",
1570
+ enum: ["PR_BODY", "COMMIT_MESSAGES", "BLANK"],
1571
+ description: `Sets the default value for a squash merge commit message. The default value is 'COMMIT_MESSAGES'`
1572
+ };
1466
1573
  const allowRebaseMerge = {
1467
1574
  title: "Allow Rebase Merges",
1468
1575
  type: "boolean",
@@ -1484,8 +1591,7 @@ const collaborators = {
1484
1591
  properties: {
1485
1592
  access: {
1486
1593
  type: "string",
1487
- description: "The type of access for the user",
1488
- enum: ["push", "pull", "admin", "maintain", "triage"]
1594
+ description: "The type of access for the user"
1489
1595
  },
1490
1596
  user: {
1491
1597
  type: "string",
@@ -1610,6 +1716,8 @@ function createGithubRepoCreateAction(options) {
1610
1716
  deleteBranchOnMerge: deleteBranchOnMerge,
1611
1717
  allowMergeCommit: allowMergeCommit,
1612
1718
  allowSquashMerge: allowSquashMerge,
1719
+ squashMergeCommitTitle: squashMergeCommitTitle,
1720
+ squashMergeCommitMessage: squashMergeCommitMessage,
1613
1721
  allowRebaseMerge: allowRebaseMerge,
1614
1722
  allowAutoMerge: allowAutoMerge,
1615
1723
  collaborators: collaborators,
@@ -1638,6 +1746,8 @@ function createGithubRepoCreateAction(options) {
1638
1746
  deleteBranchOnMerge = false,
1639
1747
  allowMergeCommit = true,
1640
1748
  allowSquashMerge = true,
1749
+ squashMergeCommitTitle = "COMMIT_OR_PR_TITLE",
1750
+ squashMergeCommitMessage = "COMMIT_MESSAGES",
1641
1751
  allowRebaseMerge = true,
1642
1752
  allowAutoMerge = false,
1643
1753
  collaborators,
@@ -1668,6 +1778,8 @@ function createGithubRepoCreateAction(options) {
1668
1778
  deleteBranchOnMerge,
1669
1779
  allowMergeCommit,
1670
1780
  allowSquashMerge,
1781
+ squashMergeCommitTitle,
1782
+ squashMergeCommitMessage,
1671
1783
  allowRebaseMerge,
1672
1784
  allowAutoMerge,
1673
1785
  access,
@@ -2998,6 +3110,8 @@ function createPublishGithubAction(options) {
2998
3110
  gitAuthorEmail: gitAuthorEmail,
2999
3111
  allowMergeCommit: allowMergeCommit,
3000
3112
  allowSquashMerge: allowSquashMerge,
3113
+ squashMergeCommitTitle: squashMergeCommitTitle,
3114
+ squashMergeCommitMessage: squashMergeCommitMessage,
3001
3115
  allowRebaseMerge: allowRebaseMerge,
3002
3116
  allowAutoMerge: allowAutoMerge,
3003
3117
  sourcePath: sourcePath,
@@ -3039,6 +3153,8 @@ function createPublishGithubAction(options) {
3039
3153
  gitAuthorEmail,
3040
3154
  allowMergeCommit = true,
3041
3155
  allowSquashMerge = true,
3156
+ squashMergeCommitTitle = "COMMIT_OR_PR_TITLE",
3157
+ squashMergeCommitMessage = "COMMIT_MESSAGES",
3042
3158
  allowRebaseMerge = true,
3043
3159
  allowAutoMerge = false,
3044
3160
  collaborators,
@@ -3069,6 +3185,8 @@ function createPublishGithubAction(options) {
3069
3185
  deleteBranchOnMerge,
3070
3186
  allowMergeCommit,
3071
3187
  allowSquashMerge,
3188
+ squashMergeCommitTitle,
3189
+ squashMergeCommitMessage,
3072
3190
  allowRebaseMerge,
3073
3191
  allowAutoMerge,
3074
3192
  access,
@@ -3130,6 +3248,8 @@ async function serializeDirectoryContents(sourcePath, options) {
3130
3248
  dot: true,
3131
3249
  gitignore: options == null ? void 0 : options.gitignore,
3132
3250
  followSymbolicLinks: false,
3251
+ // In order to pick up 'broken' symlinks, we oxymoronically request files AND folders yet we filter out folders
3252
+ // This is because broken symlinks aren't classed as files so we need to glob everything
3133
3253
  onlyFiles: false,
3134
3254
  objectMode: true,
3135
3255
  stats: true
@@ -3327,7 +3447,16 @@ const createPublishGithubPullRequestAction = ({
3327
3447
  directoryContents.map((file) => [
3328
3448
  targetPath ? path__default["default"].posix.join(targetPath, file.path) : file.path,
3329
3449
  {
3450
+ // See the properties of tree items
3451
+ // in https://docs.github.com/en/rest/reference/git#trees
3330
3452
  mode: determineFileMode(file),
3453
+ // Always use base64 encoding where possible to avoid doubling a binary file in size
3454
+ // due to interpreting a binary file as utf-8 and sending github
3455
+ // the utf-8 encoded content. Symlinks are kept as utf-8 to avoid them
3456
+ // being formatted as a series of scrambled characters
3457
+ //
3458
+ // For example, the original gradle-wrapper.jar is 57.8k in https://github.com/kennethzfeng/pull-request-test/pull/5/files.
3459
+ // Its size could be doubled to 98.3K (See https://github.com/kennethzfeng/pull-request-test/pull/4/files)
3331
3460
  encoding: determineFileEncoding(file),
3332
3461
  content: file.content.toString(determineFileEncoding(file))
3333
3462
  }
@@ -3564,6 +3693,7 @@ const createPublishGitlabMergeRequestAction = (options) => {
3564
3693
  title: "Repository Location",
3565
3694
  description: `Accepts the format 'gitlab.com/group_name/project_name' where 'project_name' is the repository name and 'group_name' is a group or username`
3566
3695
  },
3696
+ /** @deprecated projectID is passed as query parameters in the repoUrl */
3567
3697
  projectid: {
3568
3698
  type: "string",
3569
3699
  title: "projectid",
@@ -3965,6 +4095,7 @@ class DatabaseTaskStore {
3965
4095
  const updateCount = await tx("tasks").where({ id: task.id, status: "open" }).update({
3966
4096
  status: "processing",
3967
4097
  last_heartbeat_at: this.db.fn.now(),
4098
+ // remove the secrets when moving moving to processing state.
3968
4099
  secrets: null
3969
4100
  });
3970
4101
  if (updateCount < 1) {
@@ -4115,6 +4246,7 @@ class DatabaseTaskStore {
4115
4246
  }
4116
4247
 
4117
4248
  class TaskManager {
4249
+ // Runs heartbeat internally
4118
4250
  constructor(task, storage, logger) {
4119
4251
  this.task = task;
4120
4252
  this.storage = storage;
@@ -4198,6 +4330,9 @@ class StorageTaskBroker {
4198
4330
  }
4199
4331
  return await this.storage.list({ createdBy: options == null ? void 0 : options.createdBy });
4200
4332
  }
4333
+ /**
4334
+ * {@inheritdoc TaskBroker.claim}
4335
+ */
4201
4336
  async claim() {
4202
4337
  for (; ; ) {
4203
4338
  const pendingTask = await this.storage.claimTask();
@@ -4216,6 +4351,9 @@ class StorageTaskBroker {
4216
4351
  await this.waitForDispatch();
4217
4352
  }
4218
4353
  }
4354
+ /**
4355
+ * {@inheritdoc TaskBroker.dispatch}
4356
+ */
4219
4357
  async dispatch(options) {
4220
4358
  const taskRow = await this.storage.createTask(options);
4221
4359
  this.signalDispatch();
@@ -4223,9 +4361,15 @@ class StorageTaskBroker {
4223
4361
  taskId: taskRow.taskId
4224
4362
  };
4225
4363
  }
4364
+ /**
4365
+ * {@inheritdoc TaskBroker.get}
4366
+ */
4226
4367
  async get(taskId) {
4227
4368
  return this.storage.getTask(taskId);
4228
4369
  }
4370
+ /**
4371
+ * {@inheritdoc TaskBroker.event$}
4372
+ */
4229
4373
  event$(options) {
4230
4374
  return new ObservableImpl__default["default"]((observer) => {
4231
4375
  const { taskId } = options;
@@ -4247,6 +4391,9 @@ class StorageTaskBroker {
4247
4391
  };
4248
4392
  });
4249
4393
  }
4394
+ /**
4395
+ * {@inheritdoc TaskBroker.vacuumTasks}
4396
+ */
4250
4397
  async vacuumTasks(options) {
4251
4398
  const { tasks } = await this.storage.listStaleTasks(options);
4252
4399
  await Promise.all(
@@ -4416,6 +4563,10 @@ class NunjucksWorkflowRunner {
4416
4563
  );
4417
4564
  const { integrations } = this.options;
4418
4565
  const renderTemplate = await SecureTemplater.loadRenderer({
4566
+ // TODO(blam): let's work out how we can deprecate this.
4567
+ // We shouldn't really need to be exposing these now we can deal with
4568
+ // objects in the params block.
4569
+ // Maybe we can expose a new RepoUrlPicker with secrets for V3 that provides an object already.
4419
4570
  parseRepoUrl(url) {
4420
4571
  return parseRepoUrl(url, integrations);
4421
4572
  },
@@ -4668,6 +4819,7 @@ class TaskWorker {
4668
4819
  workingDirectory,
4669
4820
  additionalTemplateFilters,
4670
4821
  concurrentTasksLimit = 10,
4822
+ // from 1 to Infinity
4671
4823
  additionalTemplateGlobals
4672
4824
  } = options;
4673
4825
  const workflowRunner = new NunjucksWorkflowRunner({
@@ -4784,6 +4936,7 @@ function createDryRunner(options) {
4784
4936
  }
4785
4937
  },
4786
4938
  secrets: input.secrets,
4939
+ // No need to update this at the end of the run, so just hard-code it
4787
4940
  done: false,
4788
4941
  isDryRun: true,
4789
4942
  getWorkspaceName: async () => `dry-run-${dryRunId}`,
@@ -4938,6 +5091,7 @@ async function createRouter(options) {
4938
5091
  await scheduler.scheduleTask({
4939
5092
  id: "close_stale_tasks",
4940
5093
  frequency: { cron: "*/5 * * * *" },
5094
+ // every 5 minutes, also supports Duration
4941
5095
  timeout: { minutes: 15 },
4942
5096
  fn: async () => {
4943
5097
  const { tasks } = await databaseTaskStore.listStaleTasks({
@@ -5026,6 +5180,7 @@ async function createRouter(options) {
5026
5180
  return {
5027
5181
  id: action.id,
5028
5182
  description: action.description,
5183
+ examples: action.examples,
5029
5184
  schema: action.schema
5030
5185
  };
5031
5186
  });
@@ -5384,7 +5539,7 @@ const scaffolderPlugin = backendPluginApi.createBackendPlugin({
5384
5539
  taskWorkers,
5385
5540
  additionalTemplateGlobals
5386
5541
  } = options;
5387
- const log = backendPluginApi.loggerToWinstonLogger(logger);
5542
+ const log = backendCommon.loggerToWinstonLogger(logger);
5388
5543
  const actions = options.actions || [
5389
5544
  ...actionsExtensions.actions,
5390
5545
  ...createBuiltinActions({