@backstage/plugin-scaffolder-backend 1.11.0 → 1.12.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.
@@ -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
@@ -8,6 +8,7 @@ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
8
8
  var yaml = require('yaml');
9
9
  var fs = require('fs-extra');
10
10
  var backendCommon = require('@backstage/backend-common');
11
+ var zod = require('zod');
11
12
  var integration = require('@backstage/integration');
12
13
  var path = require('path');
13
14
  var globby = require('globby');
@@ -36,12 +37,9 @@ var promClient = require('prom-client');
36
37
  var pluginScaffolderCommon = require('@backstage/plugin-scaffolder-common');
37
38
  var express = require('express');
38
39
  var Router = require('express-promise-router');
39
- 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
 
@@ -254,24 +252,16 @@ function createCatalogWriteAction() {
254
252
  return pluginScaffolderNode.createTemplateAction({
255
253
  id: id$2,
256
254
  description: "Writes the catalog-info.yaml for your template",
257
- examples: examples$2,
258
255
  schema: {
259
- input: {
260
- type: "object",
261
- properties: {
262
- filePath: {
263
- title: "Catalog file path",
264
- description: "Defaults to catalog-info.yaml",
265
- type: "string"
266
- },
267
- entity: {
268
- title: "Entity info to write catalog-info.yaml",
269
- description: "You can provide the same values used in the Entity schema.",
270
- type: "object"
271
- }
272
- }
273
- }
256
+ input: zod.z.object({
257
+ filePath: zod.z.string().optional().describe("Defaults to catalog-info.yaml"),
258
+ // TODO: this should reference an zod entity validator if it existed.
259
+ entity: zod.z.object({}).describe(
260
+ "You can provide the same values used in the Entity schema."
261
+ )
262
+ })
274
263
  },
264
+ examples: examples$2,
275
265
  supportsDryRun: true,
276
266
  async handler(ctx) {
277
267
  ctx.logStream.write(`Writing catalog-info.yaml`);
@@ -350,6 +340,9 @@ function createFetchCatalogEntityAction(options) {
350
340
  throw e;
351
341
  }
352
342
  }
343
+ if (!entity && !optional) {
344
+ throw new Error(`Entity ${entityRef} not found`);
345
+ }
353
346
  ctx.output("entity", entity != null ? entity : null);
354
347
  }
355
348
  });
@@ -5640,115 +5633,6 @@ class ScaffolderEntitiesProcessor {
5640
5633
  }
5641
5634
  }
5642
5635
 
5643
- const catalogModuleTemplateKind = backendPluginApi.createBackendModule({
5644
- moduleId: "scaffolder",
5645
- pluginId: "templateKind",
5646
- register(env) {
5647
- env.registerInit({
5648
- deps: {
5649
- catalog: pluginCatalogNode.catalogProcessingExtensionPoint
5650
- },
5651
- async init({ catalog }) {
5652
- catalog.addProcessor(new ScaffolderEntitiesProcessor());
5653
- }
5654
- });
5655
- }
5656
- });
5657
-
5658
- var __accessCheck = (obj, member, msg) => {
5659
- if (!member.has(obj))
5660
- throw TypeError("Cannot " + msg);
5661
- };
5662
- var __privateGet = (obj, member, getter) => {
5663
- __accessCheck(obj, member, "read from private field");
5664
- return getter ? getter.call(obj) : member.get(obj);
5665
- };
5666
- var __privateAdd = (obj, member, value) => {
5667
- if (member.has(obj))
5668
- throw TypeError("Cannot add the same private member more than once");
5669
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
5670
- };
5671
- var _actions;
5672
- class ScaffolderActionsExtensionPointImpl {
5673
- constructor() {
5674
- __privateAdd(this, _actions, new Array());
5675
- }
5676
- addActions(...actions) {
5677
- __privateGet(this, _actions).push(...actions);
5678
- }
5679
- get actions() {
5680
- return __privateGet(this, _actions);
5681
- }
5682
- }
5683
- _actions = new WeakMap();
5684
- const scaffolderPlugin = backendPluginApi.createBackendPlugin(
5685
- (options) => ({
5686
- pluginId: "scaffolder",
5687
- register(env) {
5688
- const actionsExtensions = new ScaffolderActionsExtensionPointImpl();
5689
- env.registerExtensionPoint(
5690
- pluginScaffolderNode.scaffolderActionsExtensionPoint,
5691
- actionsExtensions
5692
- );
5693
- env.registerInit({
5694
- deps: {
5695
- logger: backendPluginApi.coreServices.logger,
5696
- config: backendPluginApi.coreServices.config,
5697
- reader: backendPluginApi.coreServices.urlReader,
5698
- permissions: backendPluginApi.coreServices.permissions,
5699
- database: backendPluginApi.coreServices.database,
5700
- httpRouter: backendPluginApi.coreServices.httpRouter,
5701
- catalogClient: pluginCatalogNode.catalogServiceRef
5702
- },
5703
- async init({
5704
- logger,
5705
- config,
5706
- reader,
5707
- database,
5708
- httpRouter,
5709
- catalogClient
5710
- }) {
5711
- const {
5712
- additionalTemplateFilters,
5713
- taskBroker,
5714
- taskWorkers,
5715
- additionalTemplateGlobals
5716
- } = options;
5717
- const log = backendCommon.loggerToWinstonLogger(logger);
5718
- const actions = options.actions || [
5719
- ...actionsExtensions.actions,
5720
- ...createBuiltinActions({
5721
- integrations: integration.ScmIntegrations.fromConfig(config),
5722
- catalogClient,
5723
- reader,
5724
- config,
5725
- additionalTemplateFilters,
5726
- additionalTemplateGlobals
5727
- })
5728
- ];
5729
- const actionIds = actions.map((action) => action.id).join(", ");
5730
- log.info(
5731
- `Starting scaffolder with the following actions enabled ${actionIds}`
5732
- );
5733
- const router = await createRouter({
5734
- logger: log,
5735
- config,
5736
- database,
5737
- catalogClient,
5738
- reader,
5739
- actions,
5740
- taskBroker,
5741
- taskWorkers,
5742
- additionalTemplateFilters,
5743
- additionalTemplateGlobals
5744
- });
5745
- httpRouter.use(router);
5746
- }
5747
- });
5748
- }
5749
- })
5750
- );
5751
-
5752
5636
  const createTemplateAction = pluginScaffolderNode.createTemplateAction;
5753
5637
 
5754
5638
  exports.DatabaseTaskStore = DatabaseTaskStore;
@@ -5756,7 +5640,6 @@ exports.ScaffolderEntitiesProcessor = ScaffolderEntitiesProcessor;
5756
5640
  exports.TaskManager = TaskManager;
5757
5641
  exports.TaskWorker = TaskWorker;
5758
5642
  exports.TemplateActionRegistry = TemplateActionRegistry;
5759
- exports.catalogModuleTemplateKind = catalogModuleTemplateKind;
5760
5643
  exports.createBuiltinActions = createBuiltinActions;
5761
5644
  exports.createCatalogRegisterAction = createCatalogRegisterAction;
5762
5645
  exports.createCatalogWriteAction = createCatalogWriteAction;
@@ -5785,5 +5668,4 @@ exports.createRouter = createRouter;
5785
5668
  exports.createTemplateAction = createTemplateAction;
5786
5669
  exports.executeShellCommand = executeShellCommand;
5787
5670
  exports.fetchContents = fetchContents;
5788
- exports.scaffolderPlugin = scaffolderPlugin;
5789
5671
  //# sourceMappingURL=index.cjs.js.map