@backstage/plugin-scaffolder-backend 0.0.0-nightly-20220301023335 → 0.0.0-nightly-20220305022735

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,17 +1,47 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
- ## 0.0.0-nightly-20220301023335
3
+ ## 0.0.0-nightly-20220305022735
4
+
5
+ ### Minor Changes
6
+
7
+ - f9c7bdd899: **BREAKING**:
8
+
9
+ - Removed the `createFetchCookiecutterAction` export, please use the `@backstage/plugin-scaffolder-backend-module-cookiecutter` package explicitly (see [its README](https://github.com/backstage/backstage/tree/master/plugins/scaffolder-backend-module-cookiecutter) for installation instructions).
10
+ - Removed the `containerRunner` argument from the types `RouterOptions` (as used by `createRouter`) and `CreateBuiltInActionsOptions` (as used by `createBuiltinActions`).
11
+
12
+ - 5afbd16d43: **BREAKING**: Removed the previously deprecated `OctokitProvider` class.
13
+
14
+ ### Patch Changes
15
+
16
+ - 458d16869c: Allow passing more repo configuration for `publish:github` action
17
+ - Updated dependencies
18
+ - @backstage/plugin-catalog-backend@0.0.0-nightly-20220305022735
19
+ - @backstage/catalog-model@0.0.0-nightly-20220305022735
20
+ - @backstage/backend-common@0.0.0-nightly-20220305022735
21
+ - @backstage/catalog-client@0.0.0-nightly-20220305022735
22
+ - @backstage/plugin-scaffolder-common@0.0.0-nightly-20220305022735
23
+
24
+ ## 0.17.3
4
25
 
5
26
  ### Patch Changes
6
27
 
7
28
  - 5c7f2343ea: Applied fix from version 0.17.2 of this package, which is part of the v0.69.2 release of Backstage.
29
+ - 899f196af5: Use `getEntityByRef` instead of `getEntityByName` in the catalog client
30
+ - 34af86517c: ensure `apiBaseUrl` being set for Bitbucket integrations, replace hardcoded defaults
8
31
  - d6deb5e440: Set timeout for scaffolder octokit client
32
+ - 83a83381b0: Use the new `processingResult` export from the catalog backend
9
33
  - 7372f29473: Cleanup API report
10
34
  - c7f6424a26: Applied fix from `v0.17.1` of this package which is part of the `v0.69.1` release of Backstage.
35
+ - 36aa63022b: Use `CompoundEntityRef` instead of `EntityName`, and `getCompoundEntityRef` instead of `getEntityName`, from `@backstage/catalog-model`.
11
36
  - 8119a9e011: Fix the support for custom defaultBranch values for Bitbucket Cloud at the `publish:bitbucket` scaffolder action.
12
37
  - Updated dependencies
13
- - @backstage/plugin-catalog-backend@0.0.0-nightly-20220301023335
14
- - @backstage/integration@0.0.0-nightly-20220301023335
38
+ - @backstage/catalog-model@0.12.0
39
+ - @backstage/catalog-client@0.8.0
40
+ - @backstage/plugin-catalog-backend@0.23.0
41
+ - @backstage/backend-common@0.12.0
42
+ - @backstage/integration@0.8.0
43
+ - @backstage/plugin-scaffolder-backend-module-cookiecutter@0.2.3
44
+ - @backstage/plugin-scaffolder-common@0.2.3
15
45
 
16
46
  ## 0.17.2
17
47
 
package/dist/index.cjs.js CHANGED
@@ -12,7 +12,6 @@ var path = require('path');
12
12
  var globby = require('globby');
13
13
  var isbinaryfile = require('isbinaryfile');
14
14
  var vm2 = require('vm2');
15
- var pluginScaffolderBackendModuleCookiecutter = require('@backstage/plugin-scaffolder-backend-module-cookiecutter');
16
15
  var child_process = require('child_process');
17
16
  var stream = require('stream');
18
17
  var azureDevopsNodeApi = require('azure-devops-node-api');
@@ -939,7 +938,8 @@ const createBitbucketCloudRepository = async (opts) => {
939
938
  description,
940
939
  repoVisibility,
941
940
  mainBranch,
942
- authorization
941
+ authorization,
942
+ apiBaseUrl
943
943
  } = opts;
944
944
  const options = {
945
945
  method: "POST",
@@ -956,7 +956,7 @@ const createBitbucketCloudRepository = async (opts) => {
956
956
  };
957
957
  let response;
958
958
  try {
959
- response = await fetch__default["default"](`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo}`, options);
959
+ response = await fetch__default["default"](`${apiBaseUrl}/repositories/${workspace}/${repo}`, options);
960
960
  } catch (e) {
961
961
  throw new Error(`Unable to create repository, ${e}`);
962
962
  }
@@ -975,7 +975,6 @@ const createBitbucketCloudRepository = async (opts) => {
975
975
  };
976
976
  const createBitbucketServerRepository = async (opts) => {
977
977
  const {
978
- host,
979
978
  project,
980
979
  repo,
981
980
  description,
@@ -997,8 +996,7 @@ const createBitbucketServerRepository = async (opts) => {
997
996
  }
998
997
  };
999
998
  try {
1000
- const baseUrl = apiBaseUrl ? apiBaseUrl : `https://${host}/rest/api/1.0`;
1001
- response = await fetch__default["default"](`${baseUrl}/projects/${project}/repos`, options);
999
+ response = await fetch__default["default"](`${apiBaseUrl}/projects/${project}/repos`, options);
1002
1000
  } catch (e) {
1003
1001
  throw new Error(`Unable to create repository, ${e}`);
1004
1002
  }
@@ -1118,12 +1116,15 @@ function createPublishBitbucketAction(options) {
1118
1116
  if (!integrationConfig) {
1119
1117
  throw new errors.InputError(`No matching integration configuration for host ${host}, please check your integrations config`);
1120
1118
  }
1121
- const authorization = getAuthorizationHeader(ctx.input.token ? { host: integrationConfig.config.host, token: ctx.input.token } : integrationConfig.config);
1119
+ const authorization = getAuthorizationHeader(ctx.input.token ? {
1120
+ host: integrationConfig.config.host,
1121
+ apiBaseUrl: integrationConfig.config.apiBaseUrl,
1122
+ token: ctx.input.token
1123
+ } : integrationConfig.config);
1122
1124
  const apiBaseUrl = integrationConfig.config.apiBaseUrl;
1123
1125
  const createMethod = host === "bitbucket.org" ? createBitbucketCloudRepository : createBitbucketServerRepository;
1124
1126
  const { remoteUrl, repoContentsUrl } = await createMethod({
1125
1127
  authorization,
1126
- host,
1127
1128
  workspace: workspace || "",
1128
1129
  project,
1129
1130
  repo,
@@ -1270,6 +1271,26 @@ function createPublishGithubAction(options) {
1270
1271
  type: "string",
1271
1272
  description: `Sets the default branch on the repository. The default value is 'master'`
1272
1273
  },
1274
+ deleteBranchOnMerge: {
1275
+ title: "Delete Branch On Merge",
1276
+ type: "boolean",
1277
+ description: `Delete the branch after merging the PR. The default value is 'false'`
1278
+ },
1279
+ allowMergeCommit: {
1280
+ title: "Allow Merge Commits",
1281
+ type: "boolean",
1282
+ description: `Allow merge commits. The default value is 'true'`
1283
+ },
1284
+ allowSquashMerge: {
1285
+ title: "Allow Squash Merges",
1286
+ type: "boolean",
1287
+ description: `Allow squash merges. The default value is 'true'`
1288
+ },
1289
+ allowRebaseMerge: {
1290
+ title: "Allow Rebase Merges",
1291
+ type: "boolean",
1292
+ description: `Allow rebase merges. The default value is 'true'`
1293
+ },
1273
1294
  sourcePath: {
1274
1295
  title: "Source Path",
1275
1296
  description: "Path within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.",
@@ -1331,6 +1352,10 @@ function createPublishGithubAction(options) {
1331
1352
  requireCodeOwnerReviews = false,
1332
1353
  repoVisibility = "private",
1333
1354
  defaultBranch = "master",
1355
+ deleteBranchOnMerge = false,
1356
+ allowMergeCommit = true,
1357
+ allowSquashMerge = true,
1358
+ allowRebaseMerge = true,
1334
1359
  collaborators,
1335
1360
  topics,
1336
1361
  token: providedToken
@@ -1354,11 +1379,19 @@ function createPublishGithubAction(options) {
1354
1379
  org: owner,
1355
1380
  private: repoVisibility === "private",
1356
1381
  visibility: repoVisibility,
1357
- description
1382
+ description,
1383
+ delete_branch_on_merge: deleteBranchOnMerge,
1384
+ allow_merge_commit: allowMergeCommit,
1385
+ allow_squash_merge: allowSquashMerge,
1386
+ allow_rebase_merge: allowRebaseMerge
1358
1387
  }) : client.rest.repos.createForAuthenticatedUser({
1359
1388
  name: repo,
1360
1389
  private: repoVisibility === "private",
1361
- description
1390
+ description,
1391
+ delete_branch_on_merge: deleteBranchOnMerge,
1392
+ allow_merge_commit: allowMergeCommit,
1393
+ allow_squash_merge: allowSquashMerge,
1394
+ allow_rebase_merge: allowRebaseMerge
1362
1395
  });
1363
1396
  const { data: newRepo } = await repoCreationPromise;
1364
1397
  if (access == null ? void 0 : access.startsWith(`${owner}/`)) {
@@ -2008,49 +2041,10 @@ function createGithubWebhookAction(options) {
2008
2041
  });
2009
2042
  }
2010
2043
 
2011
- class OctokitProvider {
2012
- constructor(integrations, githubCredentialsProvider) {
2013
- this.integrations = integrations;
2014
- this.githubCredentialsProvider = githubCredentialsProvider || integration.DefaultGithubCredentialsProvider.fromIntegrations(this.integrations);
2015
- }
2016
- async getOctokit(repoUrl, options) {
2017
- var _a;
2018
- const { owner, repo, host } = parseRepoUrl(repoUrl, this.integrations);
2019
- if (!owner) {
2020
- throw new errors.InputError(`No owner provided for repo ${repoUrl}`);
2021
- }
2022
- const integrationConfig = (_a = this.integrations.github.byHost(host)) == null ? void 0 : _a.config;
2023
- if (!integrationConfig) {
2024
- throw new errors.InputError(`No integration for host ${host}`);
2025
- }
2026
- if (options == null ? void 0 : options.token) {
2027
- const client2 = new octokit.Octokit({
2028
- auth: options.token,
2029
- baseUrl: integrationConfig.apiBaseUrl,
2030
- previews: ["nebula-preview"]
2031
- });
2032
- return { client: client2, token: options.token, owner, repo };
2033
- }
2034
- const { token } = await this.githubCredentialsProvider.getCredentials({
2035
- url: `https://${host}/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`
2036
- });
2037
- if (!token) {
2038
- throw new errors.InputError(`No token available for host: ${host}, with owner ${owner}, and repo ${repo}`);
2039
- }
2040
- const client = new octokit.Octokit({
2041
- auth: token,
2042
- baseUrl: integrationConfig.apiBaseUrl,
2043
- previews: ["nebula-preview"]
2044
- });
2045
- return { client, token, owner, repo };
2046
- }
2047
- }
2048
-
2049
2044
  const createBuiltinActions = (options) => {
2050
2045
  const {
2051
2046
  reader,
2052
2047
  integrations,
2053
- containerRunner,
2054
2048
  catalogClient,
2055
2049
  config,
2056
2050
  additionalTemplateFilters
@@ -2104,16 +2098,6 @@ const createBuiltinActions = (options) => {
2104
2098
  githubCredentialsProvider
2105
2099
  })
2106
2100
  ];
2107
- if (containerRunner) {
2108
- backendCommon.getRootLogger().warn(`[DEPRECATED] The fetch:cookiecutter action will be removed part of the default scaffolder actions in later versions.
2109
- You can install the package seperately and remove the containerRunner from the createBuiltInActions to remove this warning,
2110
- or you can migrate to using fetch:template https://backstage.io/docs/features/software-templates/builtin-actions#migrating-from-fetchcookiecutter-to-fetchtemplate`);
2111
- actions.push(pluginScaffolderBackendModuleCookiecutter.createFetchCookiecutterAction({
2112
- reader,
2113
- integrations,
2114
- containerRunner
2115
- }));
2116
- }
2117
2101
  return actions;
2118
2102
  };
2119
2103
 
@@ -2872,9 +2856,9 @@ async function findTemplate(options) {
2872
2856
  if (entityRef.kind.toLocaleLowerCase("en-US") !== "template") {
2873
2857
  throw new errors.InputError(`Invalid kind, only 'Template' kind is supported`);
2874
2858
  }
2875
- const template = await catalogApi.getEntityByName(entityRef, { token });
2859
+ const template = await catalogApi.getEntityByRef(entityRef, { token });
2876
2860
  if (!template) {
2877
- throw new errors.NotFoundError(`Template ${entityRef} not found`);
2861
+ throw new errors.NotFoundError(`Template ${catalogModel.stringifyEntityRef(entityRef)} not found`);
2878
2862
  }
2879
2863
  return template;
2880
2864
  }
@@ -2892,7 +2876,6 @@ async function createRouter(options) {
2892
2876
  database,
2893
2877
  catalogClient,
2894
2878
  actions,
2895
- containerRunner,
2896
2879
  taskWorkers,
2897
2880
  additionalTemplateFilters
2898
2881
  } = options;
@@ -2924,7 +2907,6 @@ async function createRouter(options) {
2924
2907
  const actionsToRegister = Array.isArray(actions) ? actions : createBuiltinActions({
2925
2908
  integrations,
2926
2909
  catalogClient,
2927
- containerRunner,
2928
2910
  reader,
2929
2911
  config,
2930
2912
  additionalTemplateFilters
@@ -3119,7 +3101,7 @@ class ScaffolderEntitiesProcessor {
3119
3101
  return false;
3120
3102
  }
3121
3103
  async postProcessEntity(entity, _location, emit) {
3122
- const selfRef = catalogModel.getEntityName(entity);
3104
+ const selfRef = catalogModel.getCompoundEntityRef(entity);
3123
3105
  if (entity.apiVersion === "scaffolder.backstage.io/v1beta3" && entity.kind === "Template") {
3124
3106
  const template = entity;
3125
3107
  const target = template.spec.owner;
@@ -3128,7 +3110,7 @@ class ScaffolderEntitiesProcessor {
3128
3110
  defaultKind: "Group",
3129
3111
  defaultNamespace: selfRef.namespace
3130
3112
  });
3131
- emit(pluginCatalogBackend.results.relation({
3113
+ emit(pluginCatalogBackend.processingResult.relation({
3132
3114
  source: selfRef,
3133
3115
  type: catalogModel.RELATION_OWNED_BY,
3134
3116
  target: {
@@ -3137,7 +3119,7 @@ class ScaffolderEntitiesProcessor {
3137
3119
  name: targetRef.name
3138
3120
  }
3139
3121
  }));
3140
- emit(pluginCatalogBackend.results.relation({
3122
+ emit(pluginCatalogBackend.processingResult.relation({
3141
3123
  source: {
3142
3124
  kind: targetRef.kind,
3143
3125
  namespace: targetRef.namespace,
@@ -3152,12 +3134,7 @@ class ScaffolderEntitiesProcessor {
3152
3134
  }
3153
3135
  }
3154
3136
 
3155
- Object.defineProperty(exports, 'createFetchCookiecutterAction', {
3156
- enumerable: true,
3157
- get: function () { return pluginScaffolderBackendModuleCookiecutter.createFetchCookiecutterAction; }
3158
- });
3159
3137
  exports.DatabaseTaskStore = DatabaseTaskStore;
3160
- exports.OctokitProvider = OctokitProvider;
3161
3138
  exports.ScaffolderEntitiesProcessor = ScaffolderEntitiesProcessor;
3162
3139
  exports.TaskManager = TaskManager;
3163
3140
  exports.TaskWorker = TaskWorker;