@backstage/plugin-scaffolder-backend 1.11.0-next.2 → 1.11.1-next.0

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.
@@ -0,0 +1,31 @@
1
+ import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
+ import { TemplateAction } from '@backstage/plugin-scaffolder-node';
3
+ import { TaskBroker, TemplateFilter, TemplateGlobal } from '@backstage/plugin-scaffolder-backend';
4
+
5
+ /**
6
+ * Registers support for the Template kind to the catalog backend plugin.
7
+ *
8
+ * @alpha
9
+ */
10
+ declare const catalogModuleTemplateKind: () => _backstage_backend_plugin_api.BackendFeature;
11
+
12
+ /**
13
+ * Catalog plugin options
14
+ *
15
+ * @alpha
16
+ */
17
+ declare type ScaffolderPluginOptions = {
18
+ actions?: TemplateAction<any>[];
19
+ taskWorkers?: number;
20
+ taskBroker?: TaskBroker;
21
+ additionalTemplateFilters?: Record<string, TemplateFilter>;
22
+ additionalTemplateGlobals?: Record<string, TemplateGlobal>;
23
+ };
24
+ /**
25
+ * Catalog plugin
26
+ *
27
+ * @alpha
28
+ */
29
+ declare const scaffolderPlugin: (options: ScaffolderPluginOptions) => _backstage_backend_plugin_api.BackendFeature;
30
+
31
+ export { ScaffolderPluginOptions, catalogModuleTemplateKind, scaffolderPlugin };
package/dist/index.cjs.js CHANGED
@@ -40,8 +40,6 @@ var zod = require('zod');
40
40
  var url = require('url');
41
41
  var os = require('os');
42
42
  var pluginCatalogBackend = require('@backstage/plugin-catalog-backend');
43
- var backendPluginApi = require('@backstage/backend-plugin-api');
44
- var pluginCatalogNode = require('@backstage/plugin-catalog-node');
45
43
 
46
44
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
47
45
 
@@ -350,6 +348,9 @@ function createFetchCatalogEntityAction(options) {
350
348
  throw e;
351
349
  }
352
350
  }
351
+ if (!entity && !optional) {
352
+ throw new Error(`Entity ${entityRef} not found`);
353
+ }
353
354
  ctx.output("entity", entity != null ? entity : null);
354
355
  }
355
356
  });
@@ -1269,6 +1270,9 @@ async function createGithubRepoWithCollaboratorsAndTopics(client, repo, owner, r
1269
1270
  const user = await client.rest.users.getByUsername({
1270
1271
  username: owner
1271
1272
  });
1273
+ if (access == null ? void 0 : access.startsWith(`${owner}/`)) {
1274
+ await validateAccessTeam(client, access);
1275
+ }
1272
1276
  const repoCreationPromise = user.data.type === "Organization" ? client.rest.repos.createInOrg({
1273
1277
  name: repo,
1274
1278
  org: owner,
@@ -1427,6 +1431,21 @@ function extractCollaboratorName(collaborator) {
1427
1431
  return collaborator.user;
1428
1432
  return collaborator.team;
1429
1433
  }
1434
+ async function validateAccessTeam(client, access) {
1435
+ const [org, team_slug] = access.split("/");
1436
+ try {
1437
+ await client.rest.teams.getByName({
1438
+ org,
1439
+ team_slug
1440
+ });
1441
+ } catch (e) {
1442
+ if (e.response.data.message === "Not Found") {
1443
+ const message = `Received 'Not Found' from the API; one of org:
1444
+ ${org} or team: ${team_slug} was not found within GitHub.`;
1445
+ throw new errors.NotFoundError(message);
1446
+ }
1447
+ }
1448
+ }
1430
1449
 
1431
1450
  function createGithubActionsDispatchAction(options) {
1432
1451
  const { integrations, githubCredentialsProvider } = options;
@@ -5622,115 +5641,6 @@ class ScaffolderEntitiesProcessor {
5622
5641
  }
5623
5642
  }
5624
5643
 
5625
- const catalogModuleTemplateKind = backendPluginApi.createBackendModule({
5626
- moduleId: "scaffolder",
5627
- pluginId: "templateKind",
5628
- register(env) {
5629
- env.registerInit({
5630
- deps: {
5631
- catalog: pluginCatalogNode.catalogProcessingExtensionPoint
5632
- },
5633
- async init({ catalog }) {
5634
- catalog.addProcessor(new ScaffolderEntitiesProcessor());
5635
- }
5636
- });
5637
- }
5638
- });
5639
-
5640
- var __accessCheck = (obj, member, msg) => {
5641
- if (!member.has(obj))
5642
- throw TypeError("Cannot " + msg);
5643
- };
5644
- var __privateGet = (obj, member, getter) => {
5645
- __accessCheck(obj, member, "read from private field");
5646
- return getter ? getter.call(obj) : member.get(obj);
5647
- };
5648
- var __privateAdd = (obj, member, value) => {
5649
- if (member.has(obj))
5650
- throw TypeError("Cannot add the same private member more than once");
5651
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
5652
- };
5653
- var _actions;
5654
- class ScaffolderActionsExtensionPointImpl {
5655
- constructor() {
5656
- __privateAdd(this, _actions, new Array());
5657
- }
5658
- addActions(...actions) {
5659
- __privateGet(this, _actions).push(...actions);
5660
- }
5661
- get actions() {
5662
- return __privateGet(this, _actions);
5663
- }
5664
- }
5665
- _actions = new WeakMap();
5666
- const scaffolderPlugin = backendPluginApi.createBackendPlugin(
5667
- (options) => ({
5668
- pluginId: "scaffolder",
5669
- register(env) {
5670
- const actionsExtensions = new ScaffolderActionsExtensionPointImpl();
5671
- env.registerExtensionPoint(
5672
- pluginScaffolderNode.scaffolderActionsExtensionPoint,
5673
- actionsExtensions
5674
- );
5675
- env.registerInit({
5676
- deps: {
5677
- logger: backendPluginApi.coreServices.logger,
5678
- config: backendPluginApi.coreServices.config,
5679
- reader: backendPluginApi.coreServices.urlReader,
5680
- permissions: backendPluginApi.coreServices.permissions,
5681
- database: backendPluginApi.coreServices.database,
5682
- httpRouter: backendPluginApi.coreServices.httpRouter,
5683
- catalogClient: pluginCatalogNode.catalogServiceRef
5684
- },
5685
- async init({
5686
- logger,
5687
- config,
5688
- reader,
5689
- database,
5690
- httpRouter,
5691
- catalogClient
5692
- }) {
5693
- const {
5694
- additionalTemplateFilters,
5695
- taskBroker,
5696
- taskWorkers,
5697
- additionalTemplateGlobals
5698
- } = options;
5699
- const log = backendCommon.loggerToWinstonLogger(logger);
5700
- const actions = options.actions || [
5701
- ...actionsExtensions.actions,
5702
- ...createBuiltinActions({
5703
- integrations: integration.ScmIntegrations.fromConfig(config),
5704
- catalogClient,
5705
- reader,
5706
- config,
5707
- additionalTemplateFilters,
5708
- additionalTemplateGlobals
5709
- })
5710
- ];
5711
- const actionIds = actions.map((action) => action.id).join(", ");
5712
- log.info(
5713
- `Starting scaffolder with the following actions enabled ${actionIds}`
5714
- );
5715
- const router = await createRouter({
5716
- logger: log,
5717
- config,
5718
- database,
5719
- catalogClient,
5720
- reader,
5721
- actions,
5722
- taskBroker,
5723
- taskWorkers,
5724
- additionalTemplateFilters,
5725
- additionalTemplateGlobals
5726
- });
5727
- httpRouter.use(router);
5728
- }
5729
- });
5730
- }
5731
- })
5732
- );
5733
-
5734
5644
  const createTemplateAction = pluginScaffolderNode.createTemplateAction;
5735
5645
 
5736
5646
  exports.DatabaseTaskStore = DatabaseTaskStore;
@@ -5738,7 +5648,6 @@ exports.ScaffolderEntitiesProcessor = ScaffolderEntitiesProcessor;
5738
5648
  exports.TaskManager = TaskManager;
5739
5649
  exports.TaskWorker = TaskWorker;
5740
5650
  exports.TemplateActionRegistry = TemplateActionRegistry;
5741
- exports.catalogModuleTemplateKind = catalogModuleTemplateKind;
5742
5651
  exports.createBuiltinActions = createBuiltinActions;
5743
5652
  exports.createCatalogRegisterAction = createCatalogRegisterAction;
5744
5653
  exports.createCatalogWriteAction = createCatalogWriteAction;
@@ -5767,5 +5676,4 @@ exports.createRouter = createRouter;
5767
5676
  exports.createTemplateAction = createTemplateAction;
5768
5677
  exports.executeShellCommand = executeShellCommand;
5769
5678
  exports.fetchContents = fetchContents;
5770
- exports.scaffolderPlugin = scaffolderPlugin;
5771
5679
  //# sourceMappingURL=index.cjs.js.map