@backstage/plugin-scaffolder-backend 0.18.0 → 1.1.0-next.1

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,54 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
+ ## 1.1.0-next.1
4
+
5
+ ### Minor Changes
6
+
7
+ - 2a7d52ca2c: Override default commit message and author details in GitLab action
8
+ - f5f921dafb: Add new `draft` option to the `publish:github:pull-request` action.
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+ - @backstage/plugin-catalog-backend@1.1.0-next.1
14
+ - @backstage/integration@1.1.0-next.1
15
+ - @backstage/backend-common@0.13.2-next.1
16
+
17
+ ## 1.0.1-next.0
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies
22
+ - @backstage/catalog-model@1.0.1-next.0
23
+ - @backstage/plugin-catalog-backend@1.0.1-next.0
24
+ - @backstage/backend-common@0.13.2-next.0
25
+ - @backstage/integration@1.0.1-next.0
26
+ - @backstage/catalog-client@1.0.1-next.0
27
+ - @backstage/plugin-scaffolder-common@1.0.1-next.0
28
+
29
+ ## 1.0.0
30
+
31
+ ### Major Changes
32
+
33
+ - b58c70c223: This package has been promoted to v1.0! To understand how this change affects the package, please check out our [versioning policy](https://backstage.io/docs/overview/versioning-policy).
34
+
35
+ ### Patch Changes
36
+
37
+ - 765639f98c: Added new `github:issues:label` action to apply labels to issues, and also output `pullRequestNumber` from `publish:github:pull-request`.
38
+ - efc73db10c: Use `better-sqlite3` instead of `@vscode/sqlite3`
39
+ - c8475ab3bb: Adding some documentation for exported things
40
+ - f24ef7864e: Minor typo fixes
41
+ - Updated dependencies
42
+ - @backstage/plugin-catalog-backend@1.0.0
43
+ - @backstage/backend-common@0.13.1
44
+ - @backstage/catalog-model@1.0.0
45
+ - @backstage/plugin-scaffolder-common@1.0.0
46
+ - @backstage/integration@1.0.0
47
+ - @backstage/catalog-client@1.0.0
48
+ - @backstage/config@1.0.0
49
+ - @backstage/errors@1.0.0
50
+ - @backstage/types@1.0.0
51
+
3
52
  ## 0.18.0
4
53
 
5
54
  ### Minor Changes
package/dist/index.cjs.js CHANGED
@@ -1528,6 +1528,11 @@ const createPublishGithubPullRequestAction = ({
1528
1528
  title: "Pull Request Description",
1529
1529
  description: "The description of the pull request"
1530
1530
  },
1531
+ draft: {
1532
+ type: "boolean",
1533
+ title: "Create as Draft",
1534
+ description: "Create a draft pull request"
1535
+ },
1531
1536
  sourcePath: {
1532
1537
  type: "string",
1533
1538
  title: "Working Subdirectory",
@@ -1553,6 +1558,11 @@ const createPublishGithubPullRequestAction = ({
1553
1558
  type: "string",
1554
1559
  title: "Pull Request URL",
1555
1560
  description: "Link to the pull request in Github"
1561
+ },
1562
+ pullRequestNumber: {
1563
+ type: "number",
1564
+ title: "Pull Request Number",
1565
+ description: "The pull request number"
1556
1566
  }
1557
1567
  }
1558
1568
  }
@@ -1563,6 +1573,7 @@ const createPublishGithubPullRequestAction = ({
1563
1573
  branchName,
1564
1574
  title,
1565
1575
  description,
1576
+ draft,
1566
1577
  targetPath,
1567
1578
  sourcePath,
1568
1579
  token: providedToken
@@ -1613,12 +1624,14 @@ const createPublishGithubPullRequestAction = ({
1613
1624
  title,
1614
1625
  changes,
1615
1626
  body: description,
1616
- head: branchName
1627
+ head: branchName,
1628
+ draft
1617
1629
  });
1618
1630
  if (!response) {
1619
1631
  throw new GithubResponseError("null response from Github");
1620
1632
  }
1621
1633
  ctx.output("remoteUrl", response.data.html_url);
1634
+ ctx.output("pullRequestNumber", response.data.number);
1622
1635
  } catch (e) {
1623
1636
  throw new GithubResponseError("Pull request creation failed", e);
1624
1637
  }
@@ -1650,6 +1663,21 @@ function createPublishGitlabAction(options) {
1650
1663
  type: "string",
1651
1664
  description: `Sets the default branch on the repository. The default value is 'master'`
1652
1665
  },
1666
+ gitCommitMessage: {
1667
+ title: "Git Commit Message",
1668
+ type: "string",
1669
+ description: `Sets the commit message on the repository. The default value is 'initial commit'`
1670
+ },
1671
+ gitAuthorName: {
1672
+ title: "Default Author Name",
1673
+ type: "string",
1674
+ description: `Sets the default author name for the commit. The default value is 'Scaffolder'`
1675
+ },
1676
+ gitAuthorEmail: {
1677
+ title: "Default Author Email",
1678
+ type: "string",
1679
+ description: `Sets the default author email for the commit.`
1680
+ },
1653
1681
  sourcePath: {
1654
1682
  title: "Source Path",
1655
1683
  description: "Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.",
@@ -1680,7 +1708,10 @@ function createPublishGitlabAction(options) {
1680
1708
  const {
1681
1709
  repoUrl,
1682
1710
  repoVisibility = "private",
1683
- defaultBranch = "master"
1711
+ defaultBranch = "master",
1712
+ gitCommitMessage = "initial commit",
1713
+ gitAuthorName,
1714
+ gitAuthorEmail
1684
1715
  } = ctx.input;
1685
1716
  const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);
1686
1717
  if (!owner) {
@@ -1712,8 +1743,8 @@ function createPublishGitlabAction(options) {
1712
1743
  const remoteUrl = http_url_to_repo.replace(/\.git$/, "");
1713
1744
  const repoContentsUrl = `${remoteUrl}/-/blob/${defaultBranch}`;
1714
1745
  const gitAuthorInfo = {
1715
- name: config.getOptionalString("scaffolder.defaultAuthor.name"),
1716
- email: config.getOptionalString("scaffolder.defaultAuthor.email")
1746
+ name: gitAuthorName ? gitAuthorName : config.getOptionalString("scaffolder.defaultAuthor.name"),
1747
+ email: gitAuthorEmail ? gitAuthorEmail : config.getOptionalString("scaffolder.defaultAuthor.email")
1717
1748
  };
1718
1749
  await initRepoAndPush({
1719
1750
  dir: getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),
@@ -1724,7 +1755,7 @@ function createPublishGitlabAction(options) {
1724
1755
  password: token
1725
1756
  },
1726
1757
  logger: ctx.logger,
1727
- commitMessage: config.getOptionalString("scaffolder.defaultCommitMessage"),
1758
+ commitMessage: gitCommitMessage ? gitCommitMessage : config.getOptionalString("scaffolder.defaultCommitMessage"),
1728
1759
  gitAuthorInfo
1729
1760
  });
1730
1761
  ctx.output("remoteUrl", remoteUrl);
@@ -2038,6 +2069,70 @@ function createGithubWebhookAction(options) {
2038
2069
  });
2039
2070
  }
2040
2071
 
2072
+ function createGithubIssuesLabelAction(options) {
2073
+ const { integrations, githubCredentialsProvider } = options;
2074
+ return createTemplateAction({
2075
+ id: "github:issues:label",
2076
+ description: "Adds labels to a pull request or issue on GitHub.",
2077
+ schema: {
2078
+ input: {
2079
+ type: "object",
2080
+ required: ["repoUrl", "number", "labels"],
2081
+ properties: {
2082
+ repoUrl: {
2083
+ title: "Repository Location",
2084
+ description: `Accepts the format 'github.com?repo=reponame&owner=owner' where 'reponame' is the repository name and 'owner' is an organization or username`,
2085
+ type: "string"
2086
+ },
2087
+ number: {
2088
+ title: "Pull Request or issue number",
2089
+ description: "The pull request or issue number to add labels to",
2090
+ type: "number"
2091
+ },
2092
+ labels: {
2093
+ title: "Labels",
2094
+ description: "The labels to add to the pull request or issue",
2095
+ type: "array",
2096
+ items: {
2097
+ type: "string"
2098
+ }
2099
+ },
2100
+ token: {
2101
+ title: "Authentication Token",
2102
+ type: "string",
2103
+ description: "The GITHUB_TOKEN to use for authorization to GitHub"
2104
+ }
2105
+ }
2106
+ }
2107
+ },
2108
+ async handler(ctx) {
2109
+ const { repoUrl, number, labels, token: providedToken } = ctx.input;
2110
+ const { owner, repo } = parseRepoUrl(repoUrl, integrations);
2111
+ ctx.logger.info(`Adding labels to ${number} issue on repo ${repo}`);
2112
+ if (!owner) {
2113
+ throw new errors.InputError("Invalid repository owner provided in repoUrl");
2114
+ }
2115
+ const client = new octokit.Octokit(await getOctokitOptions({
2116
+ integrations,
2117
+ credentialsProvider: githubCredentialsProvider,
2118
+ repoUrl,
2119
+ token: providedToken
2120
+ }));
2121
+ try {
2122
+ await client.rest.issues.addLabels({
2123
+ owner,
2124
+ repo,
2125
+ issue_number: number,
2126
+ labels
2127
+ });
2128
+ } catch (e) {
2129
+ errors.assertError(e);
2130
+ ctx.logger.warn(`Failed: adding labels to issue: '${number}' on repo: '${repo}', ${e.message}`);
2131
+ }
2132
+ }
2133
+ });
2134
+ }
2135
+
2041
2136
  const createBuiltinActions = (options) => {
2042
2137
  const {
2043
2138
  reader,
@@ -2093,6 +2188,10 @@ const createBuiltinActions = (options) => {
2093
2188
  createGithubWebhookAction({
2094
2189
  integrations,
2095
2190
  githubCredentialsProvider
2191
+ }),
2192
+ createGithubIssuesLabelAction({
2193
+ integrations,
2194
+ githubCredentialsProvider
2096
2195
  })
2097
2196
  ];
2098
2197
  return actions;
@@ -2950,6 +3049,7 @@ exports.createFetchTemplateAction = createFetchTemplateAction;
2950
3049
  exports.createFilesystemDeleteAction = createFilesystemDeleteAction;
2951
3050
  exports.createFilesystemRenameAction = createFilesystemRenameAction;
2952
3051
  exports.createGithubActionsDispatchAction = createGithubActionsDispatchAction;
3052
+ exports.createGithubIssuesLabelAction = createGithubIssuesLabelAction;
2953
3053
  exports.createGithubWebhookAction = createGithubWebhookAction;
2954
3054
  exports.createPublishAzureAction = createPublishAzureAction;
2955
3055
  exports.createPublishBitbucketAction = createPublishBitbucketAction;