@backstage/plugin-scaffolder-backend 0.0.0-nightly-202201122931 → 0.0.0-nightly-202201323044

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,22 +1,23 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
- ## 0.0.0-nightly-202201122931
3
+ ## 0.0.0-nightly-202201323044
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - 9fbd3b90ae: fix: Register plugin to prioritise Component kind for entityRef
8
8
  - 5333451def: Cleaned up API exports
9
+ - 3b4d8caff6: Allow a GitHubCredentialsProvider to be passed to the GitHub scaffolder tasks actions.
9
10
  - Updated dependencies
10
- - @backstage/config@0.0.0-nightly-202201122931
11
- - @backstage/plugin-catalog-backend@0.0.0-nightly-202201122931
12
- - @backstage/backend-common@0.0.0-nightly-202201122931
13
- - @backstage/integration@0.0.0-nightly-202201122931
14
- - @backstage/errors@0.0.0-nightly-202201122931
15
- - @backstage/catalog-client@0.0.0-nightly-202201122931
16
- - @backstage/catalog-model@0.0.0-nightly-202201122931
17
- - @backstage/types@0.0.0-nightly-202201122931
18
- - @backstage/plugin-scaffolder-backend-module-cookiecutter@0.0.0-nightly-202201122931
19
- - @backstage/plugin-scaffolder-common@0.0.0-nightly-202201122931
11
+ - @backstage/config@0.0.0-nightly-202201323044
12
+ - @backstage/integration@0.0.0-nightly-202201323044
13
+ - @backstage/backend-common@0.0.0-nightly-202201323044
14
+ - @backstage/plugin-catalog-backend@0.0.0-nightly-202201323044
15
+ - @backstage/errors@0.0.0-nightly-202201323044
16
+ - @backstage/catalog-client@0.0.0-nightly-202201323044
17
+ - @backstage/catalog-model@0.0.0-nightly-202201323044
18
+ - @backstage/types@0.0.0-nightly-202201323044
19
+ - @backstage/plugin-scaffolder-backend-module-cookiecutter@0.0.0-nightly-202201323044
20
+ - @backstage/plugin-scaffolder-common@0.0.0-nightly-202201323044
20
21
 
21
22
  ## 0.15.19
22
23
 
package/dist/index.cjs.js CHANGED
@@ -7,6 +7,7 @@ var catalogModel = require('@backstage/catalog-model');
7
7
  var fs = require('fs-extra');
8
8
  var yaml = require('yaml');
9
9
  var backendCommon = require('@backstage/backend-common');
10
+ var integration = require('@backstage/integration');
10
11
  var path = require('path');
11
12
  var globby = require('globby');
12
13
  var isbinaryfile = require('isbinaryfile');
@@ -16,7 +17,6 @@ var child_process = require('child_process');
16
17
  var stream = require('stream');
17
18
  var azureDevopsNodeApi = require('azure-devops-node-api');
18
19
  var fetch = require('node-fetch');
19
- var integration = require('@backstage/integration');
20
20
  var rest = require('@octokit/rest');
21
21
  var lodash = require('lodash');
22
22
  var octokitPluginCreatePullRequest = require('octokit-plugin-create-pull-request');
@@ -1156,12 +1156,9 @@ function createPublishFileAction() {
1156
1156
  }
1157
1157
 
1158
1158
  class OctokitProvider {
1159
- constructor(integrations) {
1159
+ constructor(integrations, githubCredentialsProvider) {
1160
1160
  this.integrations = integrations;
1161
- this.credentialsProviders = new Map(integrations.github.list().map((integration$1) => {
1162
- const provider = integration.SingleInstanceGithubCredentialsProvider.create(integration$1.config);
1163
- return [integration$1.config.host, provider];
1164
- }));
1161
+ this.githubCredentialsProvider = githubCredentialsProvider || integration.DefaultGithubCredentialsProvider.fromIntegrations(this.integrations);
1165
1162
  }
1166
1163
  async getOctokit(repoUrl) {
1167
1164
  var _a;
@@ -1173,11 +1170,7 @@ class OctokitProvider {
1173
1170
  if (!integrationConfig) {
1174
1171
  throw new errors.InputError(`No integration for host ${host}`);
1175
1172
  }
1176
- const credentialsProvider = this.credentialsProviders.get(host);
1177
- if (!credentialsProvider) {
1178
- throw new errors.InputError(`No matching credentials for host ${host}, please check your integrations config`);
1179
- }
1180
- const { token } = await credentialsProvider.getCredentials({
1173
+ const { token } = await this.githubCredentialsProvider.getCredentials({
1181
1174
  url: `https://${host}/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`
1182
1175
  });
1183
1176
  if (!token) {
@@ -1193,8 +1186,8 @@ class OctokitProvider {
1193
1186
  }
1194
1187
 
1195
1188
  function createPublishGithubAction(options) {
1196
- const { integrations, config } = options;
1197
- const octokitProvider = new OctokitProvider(integrations);
1189
+ const { integrations, config, githubCredentialsProvider } = options;
1190
+ const octokitProvider = new OctokitProvider(integrations, githubCredentialsProvider || integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations));
1198
1191
  return createTemplateAction({
1199
1192
  id: "publish:github",
1200
1193
  description: "Initializes a git repository of contents in workspace and publishes it to GitHub.",
@@ -1394,6 +1387,7 @@ class GithubResponseError extends errors.CustomErrorBase {
1394
1387
  }
1395
1388
  const defaultClientFactory = async ({
1396
1389
  integrations,
1390
+ githubCredentialsProvider,
1397
1391
  owner,
1398
1392
  repo,
1399
1393
  host = "github.com"
@@ -1403,10 +1397,7 @@ const defaultClientFactory = async ({
1403
1397
  if (!integrationConfig) {
1404
1398
  throw new errors.InputError(`No integration for host ${host}`);
1405
1399
  }
1406
- const credentialsProvider = integration.SingleInstanceGithubCredentialsProvider.create(integrationConfig);
1407
- if (!credentialsProvider) {
1408
- throw new errors.InputError(`No matching credentials for host ${host}, please check your integrations config`);
1409
- }
1400
+ const credentialsProvider = githubCredentialsProvider || integration.SingleInstanceGithubCredentialsProvider.create(integrationConfig);
1410
1401
  const { token } = await credentialsProvider.getCredentials({
1411
1402
  url: `https://${host}/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`
1412
1403
  });
@@ -1421,6 +1412,7 @@ const defaultClientFactory = async ({
1421
1412
  };
1422
1413
  const createPublishGithubPullRequestAction = ({
1423
1414
  integrations,
1415
+ githubCredentialsProvider,
1424
1416
  clientFactory = defaultClientFactory
1425
1417
  }) => {
1426
1418
  return createTemplateAction({
@@ -1487,7 +1479,13 @@ const createPublishGithubPullRequestAction = ({
1487
1479
  if (!owner) {
1488
1480
  throw new errors.InputError(`No owner provided for host: ${host}, and repo ${repo}`);
1489
1481
  }
1490
- const client = await clientFactory({ integrations, host, owner, repo });
1482
+ const client = await clientFactory({
1483
+ integrations,
1484
+ githubCredentialsProvider,
1485
+ host,
1486
+ owner,
1487
+ repo
1488
+ });
1491
1489
  const fileRoot = sourcePath ? backendCommon.resolveSafeChildPath(ctx.workspacePath, sourcePath) : ctx.workspacePath;
1492
1490
  const localFilePaths = await globby__default["default"](["./**", "./**/.*", "!.git"], {
1493
1491
  cwd: fileRoot,
@@ -1749,8 +1747,8 @@ const createPublishGitlabMergeRequestAction = (options) => {
1749
1747
  };
1750
1748
 
1751
1749
  function createGithubActionsDispatchAction(options) {
1752
- const { integrations } = options;
1753
- const octokitProvider = new OctokitProvider(integrations);
1750
+ const { integrations, githubCredentialsProvider } = options;
1751
+ const octokitProvider = new OctokitProvider(integrations, githubCredentialsProvider || integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations));
1754
1752
  return createTemplateAction({
1755
1753
  id: "github:actions:dispatch",
1756
1754
  description: "Dispatches a GitHub Action workflow for a given branch or tag",
@@ -1793,8 +1791,8 @@ function createGithubActionsDispatchAction(options) {
1793
1791
  }
1794
1792
 
1795
1793
  function createGithubWebhookAction(options) {
1796
- const { integrations, defaultWebhookSecret } = options;
1797
- const octokitProvider = new OctokitProvider(integrations);
1794
+ const { integrations, defaultWebhookSecret, githubCredentialsProvider } = options;
1795
+ const octokitProvider = new OctokitProvider(integrations, githubCredentialsProvider != null ? githubCredentialsProvider : integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations));
1798
1796
  const eventNames = webhooks.emitterEventNames.filter((event) => !event.includes("."));
1799
1797
  return createTemplateAction({
1800
1798
  id: "github:webhook",
@@ -1894,6 +1892,7 @@ function createGithubWebhookAction(options) {
1894
1892
 
1895
1893
  const createBuiltinActions = (options) => {
1896
1894
  const { reader, integrations, containerRunner, catalogClient, config } = options;
1895
+ const githubCredentialsProvider = integration.DefaultGithubCredentialsProvider.fromIntegrations(integrations);
1897
1896
  const actions = [
1898
1897
  createFetchPlainAction({
1899
1898
  reader,
@@ -1905,10 +1904,12 @@ const createBuiltinActions = (options) => {
1905
1904
  }),
1906
1905
  createPublishGithubAction({
1907
1906
  integrations,
1908
- config
1907
+ config,
1908
+ githubCredentialsProvider
1909
1909
  }),
1910
1910
  createPublishGithubPullRequestAction({
1911
- integrations
1911
+ integrations,
1912
+ githubCredentialsProvider
1912
1913
  }),
1913
1914
  createPublishGitlabAction({
1914
1915
  integrations,
@@ -1931,10 +1932,12 @@ const createBuiltinActions = (options) => {
1931
1932
  createFilesystemDeleteAction(),
1932
1933
  createFilesystemRenameAction(),
1933
1934
  createGithubActionsDispatchAction({
1934
- integrations
1935
+ integrations,
1936
+ githubCredentialsProvider
1935
1937
  }),
1936
1938
  createGithubWebhookAction({
1937
- integrations
1939
+ integrations,
1940
+ githubCredentialsProvider
1938
1941
  })
1939
1942
  ];
1940
1943
  if (containerRunner) {