@backstage/plugin-scaffolder-backend 1.15.2-next.2 → 1.16.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,60 @@
1
1
  # @backstage/plugin-scaffolder-backend
2
2
 
3
+ ## 1.16.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 2ba07bcdb046: Fixed the plugin and module ID of the alpha `catalogModuleTemplateKind` export.
8
+
9
+ ## 1.16.0
10
+
11
+ ### Minor Changes
12
+
13
+ - e514aac3eac0: Introduce `each` property on action steps, allowing them to be ran repeatedly.
14
+
15
+ ### Patch Changes
16
+
17
+ - 629cbd194a87: Use `coreServices.rootConfig` instead of `coreService.config`
18
+ - 349611126ae2: Removed the options from the alpha `scaffolderPlugin` export. To extend the scaffolder plugin you instead now use the available extension points, `scaffolderActionsExtensionPoint`, `scaffolderTaskBrokerExtensionPoint`, and `scaffolderTemplatingExtensionPoint`.
19
+ - 33c76caef72a: Added examples for the `fs:delete` and `fs:rename` actions
20
+ - e07a4914f621: Deprecated the following type exports, which have been moved to `@backstage/plugin-scaffolder-node` instead:
21
+
22
+ - `TemplateFilter`
23
+ - `TemplateGlobal`
24
+ - `TaskStatus`
25
+ - `TaskCompletionState`
26
+ - `SerializedTask`
27
+ - `TaskEventType`
28
+ - `SerializedTaskEvent`
29
+ - `TaskBrokerDispatchResult`
30
+ - `TaskBrokerDispatchOptions`
31
+ - `TaskContext`
32
+ - `TaskBroker`
33
+
34
+ - 0b1d775be05b: Adds examples to a few scaffolder actions.
35
+ - 88bc6e27a213: The `concurrentTasksLimit` option can now be configured via static configuration as well. Setting it to 0 will now also disable the task worker.
36
+ - 0f873325068d: Add examples for `github:repo:create` and `github:repo:push` scaffolder actions.
37
+ - 5c28ebc79fd6: Updated dependency `esbuild` to `^0.19.0`.
38
+ - d3b31a791eb1: Deprecated `executeShellCommand`, `RunCommandOptions`, and `fetchContents` from `@backstage/plugin-scaffolder-backend`, since they are useful for Scaffolder modules (who should not be importing from the plugin package itself). You should now import these from `@backstage/plugin-scaffolder-backend-node` instead. `RunCommandOptions` was renamed in the Node package as `ExecuteShellCommandOptions`, for consistency.
39
+ - Updated dependencies
40
+ - @backstage/backend-common@0.19.2
41
+ - @backstage/plugin-catalog-backend@1.12.0
42
+ - @backstage/backend-plugin-api@0.6.0
43
+ - @backstage/plugin-scaffolder-node@0.2.0
44
+ - @backstage/plugin-catalog-node@1.4.1
45
+ - @backstage/plugin-auth-node@0.2.17
46
+ - @backstage/integration@1.6.0
47
+ - @backstage/backend-tasks@0.5.5
48
+ - @backstage/plugin-scaffolder-common@1.4.0
49
+ - @backstage/plugin-permission-node@0.7.11
50
+ - @backstage/catalog-client@1.4.3
51
+ - @backstage/catalog-model@1.4.1
52
+ - @backstage/config@1.0.8
53
+ - @backstage/errors@1.2.1
54
+ - @backstage/types@1.1.0
55
+ - @backstage/plugin-catalog-common@1.0.15
56
+ - @backstage/plugin-permission-common@0.7.7
57
+
3
58
  ## 1.15.2-next.2
4
59
 
5
60
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-backend",
3
- "version": "1.15.2-next.2",
3
+ "version": "1.16.1",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/config.d.ts CHANGED
@@ -28,5 +28,14 @@ export interface Config {
28
28
  * The commit message used when new components are created.
29
29
  */
30
30
  defaultCommitMessage?: string;
31
+
32
+ /**
33
+ * Sets the number of concurrent tasks that can be run at any given time on the TaskWorker.
34
+ *
35
+ * Defaults to 10.
36
+ *
37
+ * Set to 0 to disable task workers altogether.
38
+ */
39
+ concurrentTasksLimit?: number;
31
40
  };
32
41
  }
package/dist/alpha.cjs.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var backendPluginApi = require('@backstage/backend-plugin-api');
6
6
  var alpha = require('@backstage/plugin-catalog-node/alpha');
7
- var ScaffolderEntitiesProcessor = require('./cjs/ScaffolderEntitiesProcessor-82f18a18.cjs.js');
7
+ var ScaffolderEntitiesProcessor = require('./cjs/ScaffolderEntitiesProcessor-4b7489dd.cjs.js');
8
8
  var alpha$1 = require('@backstage/plugin-scaffolder-common/alpha');
9
9
  var pluginPermissionNode = require('@backstage/plugin-permission-node');
10
10
  var backendCommon = require('@backstage/backend-common');
@@ -49,8 +49,8 @@ require('os');
49
49
  require('@backstage/plugin-catalog-node');
50
50
 
51
51
  const catalogModuleTemplateKind = backendPluginApi.createBackendModule({
52
- moduleId: "scaffolder",
53
- pluginId: "templateKind",
52
+ moduleId: "templateKind",
53
+ pluginId: "catalog",
54
54
  register(env) {
55
55
  env.registerInit({
56
56
  deps: {
@@ -78,101 +78,86 @@ const scaffolderTemplateConditions = templateConditionExports.conditions;
78
78
  const createScaffolderActionConditionalDecision = actionsConditionExports.createConditionalDecision;
79
79
  const scaffolderActionConditions = actionsConditionExports.conditions;
80
80
 
81
- var __accessCheck = (obj, member, msg) => {
82
- if (!member.has(obj))
83
- throw TypeError("Cannot " + msg);
84
- };
85
- var __privateGet = (obj, member, getter) => {
86
- __accessCheck(obj, member, "read from private field");
87
- return getter ? getter.call(obj) : member.get(obj);
88
- };
89
- var __privateAdd = (obj, member, value) => {
90
- if (member.has(obj))
91
- throw TypeError("Cannot add the same private member more than once");
92
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
93
- };
94
- var _actions;
95
- class ScaffolderActionsExtensionPointImpl {
96
- constructor() {
97
- __privateAdd(this, _actions, new Array());
98
- }
99
- addActions(...actions) {
100
- __privateGet(this, _actions).push(...actions);
101
- }
102
- get actions() {
103
- return __privateGet(this, _actions);
104
- }
105
- }
106
- _actions = new WeakMap();
107
- const scaffolderPlugin = backendPluginApi.createBackendPlugin(
108
- (options) => ({
109
- pluginId: "scaffolder",
110
- register(env) {
111
- const actionsExtensions = new ScaffolderActionsExtensionPointImpl();
112
- env.registerExtensionPoint(
113
- pluginScaffolderNode.scaffolderActionsExtensionPoint,
114
- actionsExtensions
115
- );
116
- env.registerInit({
117
- deps: {
118
- logger: backendPluginApi.coreServices.logger,
119
- config: backendPluginApi.coreServices.rootConfig,
120
- reader: backendPluginApi.coreServices.urlReader,
121
- permissions: backendPluginApi.coreServices.permissions,
122
- database: backendPluginApi.coreServices.database,
123
- httpRouter: backendPluginApi.coreServices.httpRouter,
124
- catalogClient: alpha.catalogServiceRef
125
- },
126
- async init({
127
- logger,
81
+ const scaffolderPlugin = backendPluginApi.createBackendPlugin({
82
+ pluginId: "scaffolder",
83
+ register(env) {
84
+ const addedActions = new Array();
85
+ env.registerExtensionPoint(pluginScaffolderNode.scaffolderActionsExtensionPoint, {
86
+ addActions(...newActions) {
87
+ addedActions.push(...newActions);
88
+ }
89
+ });
90
+ let taskBroker;
91
+ env.registerExtensionPoint(pluginScaffolderNode.scaffolderTaskBrokerExtensionPoint, {
92
+ setTaskBroker(newTaskBroker) {
93
+ if (taskBroker) {
94
+ throw new Error("Task broker may only be set once");
95
+ }
96
+ taskBroker = newTaskBroker;
97
+ }
98
+ });
99
+ const additionalTemplateFilters = {};
100
+ const additionalTemplateGlobals = {};
101
+ env.registerExtensionPoint(pluginScaffolderNode.scaffolderTemplatingExtensionPoint, {
102
+ addTemplateFilters(newFilters) {
103
+ Object.assign(additionalTemplateFilters, newFilters);
104
+ },
105
+ addTemplateGlobals(newGlobals) {
106
+ Object.assign(additionalTemplateGlobals, newGlobals);
107
+ }
108
+ });
109
+ env.registerInit({
110
+ deps: {
111
+ logger: backendPluginApi.coreServices.logger,
112
+ config: backendPluginApi.coreServices.rootConfig,
113
+ reader: backendPluginApi.coreServices.urlReader,
114
+ permissions: backendPluginApi.coreServices.permissions,
115
+ database: backendPluginApi.coreServices.database,
116
+ httpRouter: backendPluginApi.coreServices.httpRouter,
117
+ catalogClient: alpha.catalogServiceRef
118
+ },
119
+ async init({
120
+ logger,
121
+ config,
122
+ reader,
123
+ database,
124
+ httpRouter,
125
+ catalogClient,
126
+ permissions
127
+ }) {
128
+ const log = backendCommon.loggerToWinstonLogger(logger);
129
+ const actions = [
130
+ ...addedActions,
131
+ ...ScaffolderEntitiesProcessor.createBuiltinActions({
132
+ integrations: integration.ScmIntegrations.fromConfig(config),
133
+ catalogClient,
134
+ reader,
135
+ config,
136
+ additionalTemplateFilters,
137
+ additionalTemplateGlobals
138
+ })
139
+ ];
140
+ const actionIds = actions.map((action) => action.id).join(", ");
141
+ log.info(
142
+ `Starting scaffolder with the following actions enabled ${actionIds}`
143
+ );
144
+ const router = await ScaffolderEntitiesProcessor.createRouter({
145
+ logger: log,
128
146
  config,
129
- reader,
130
147
  database,
131
- httpRouter,
132
148
  catalogClient,
149
+ reader,
150
+ actions,
151
+ taskBroker,
152
+ additionalTemplateFilters,
153
+ additionalTemplateGlobals,
133
154
  permissions
134
- }) {
135
- const {
136
- additionalTemplateFilters,
137
- taskBroker,
138
- taskWorkers,
139
- additionalTemplateGlobals
140
- } = options != null ? options : {};
141
- const log = backendCommon.loggerToWinstonLogger(logger);
142
- const actions = (options == null ? void 0 : options.actions) || [
143
- ...actionsExtensions.actions,
144
- ...ScaffolderEntitiesProcessor.createBuiltinActions({
145
- integrations: integration.ScmIntegrations.fromConfig(config),
146
- catalogClient,
147
- reader,
148
- config,
149
- additionalTemplateFilters,
150
- additionalTemplateGlobals
151
- })
152
- ];
153
- const actionIds = actions.map((action) => action.id).join(", ");
154
- log.info(
155
- `Starting scaffolder with the following actions enabled ${actionIds}`
156
- );
157
- const router = await ScaffolderEntitiesProcessor.createRouter({
158
- logger: log,
159
- config,
160
- database,
161
- catalogClient,
162
- reader,
163
- actions,
164
- taskBroker,
165
- taskWorkers,
166
- additionalTemplateFilters,
167
- additionalTemplateGlobals,
168
- permissions
169
- });
170
- httpRouter.use(router);
171
- }
172
- });
173
- }
174
- })
175
- );
155
+ });
156
+ httpRouter.use(router);
157
+ }
158
+ });
159
+ }
160
+ });
176
161
 
177
162
  exports.catalogModuleTemplateKind = catalogModuleTemplateKind;
178
163
  exports.createScaffolderActionConditionalDecision = createScaffolderActionConditionalDecision;
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.cjs.js","sources":["../src/modules/catalogModuleTemplateKind.ts","../src/service/conditionExports.ts","../src/ScaffolderPlugin.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha';\nimport { ScaffolderEntitiesProcessor } from '../processor';\n\n/**\n * Registers support for the Template kind to the catalog backend plugin.\n *\n * @alpha\n */\nexport const catalogModuleTemplateKind = createBackendModule({\n moduleId: 'scaffolder',\n pluginId: 'templateKind',\n register(env) {\n env.registerInit({\n deps: {\n catalog: catalogProcessingExtensionPoint,\n },\n async init({ catalog }) {\n catalog.addProcessor(new ScaffolderEntitiesProcessor());\n },\n });\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,\n RESOURCE_TYPE_SCAFFOLDER_ACTION,\n} from '@backstage/plugin-scaffolder-common/alpha';\nimport { createConditionExports } from '@backstage/plugin-permission-node';\nimport { scaffolderTemplateRules, scaffolderActionRules } from './rules';\n\nconst templateConditionExports = createConditionExports({\n pluginId: 'scaffolder',\n resourceType: RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,\n rules: scaffolderTemplateRules,\n});\n\nconst actionsConditionExports = createConditionExports({\n pluginId: 'scaffolder',\n resourceType: RESOURCE_TYPE_SCAFFOLDER_ACTION,\n rules: scaffolderActionRules,\n});\n\n/**\n * `createScaffolderTemplateConditionalDecision` can be used when authoring policies to\n * create conditional decisions. It requires a permission of type\n * `ResourcePermission<'scaffolder-template'>` to be passed as the first parameter.\n * It's recommended that you use the provided `isResourcePermission` and\n * `isPermission` helper methods to narrow the type of the permission passed to\n * the handle method as shown below.\n *\n * ```\n * // MyAuthorizationPolicy.ts\n * ...\n * import { createScaffolderPolicyDecision } from '@backstage/plugin-scaffolder-backend';\n * import { RESOURCE_TYPE_SCAFFOLDER_TEMPLATE } from '@backstage/plugin-scaffolder-common';\n *\n * class MyAuthorizationPolicy implements PermissionPolicy {\n * async handle(request, user) {\n * ...\n *\n * if (isResourcePermission(request.permission, RESOURCE_TYPE_SCAFFOLDER_TEMPLATE)) {\n * return createScaffolderConditionalDecision(\n * request.permission,\n * { anyOf: [...insert conditions here...] }\n * );\n * }\n *\n * ...\n * }\n *\n * ```\n *\n * @alpha\n */\nexport const createScaffolderTemplateConditionalDecision =\n templateConditionExports.createConditionalDecision;\n\n/**\n * These conditions are used when creating conditional decisions for scaffolder\n * templates that are returned by authorization policies.\n *\n * @alpha\n */\nexport const scaffolderTemplateConditions = templateConditionExports.conditions;\n\n/**\n * @alpha\n */\nexport const createScaffolderActionConditionalDecision =\n actionsConditionExports.createConditionalDecision;\n\n/**\n *\n * These conditions are used when creating conditional decisions for scaffolder\n * actions that are returned by authorization policies.\n *\n * @alpha\n */\nexport const scaffolderActionConditions = actionsConditionExports.conditions;\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';\nimport {\n scaffolderActionsExtensionPoint,\n ScaffolderActionsExtensionPoint,\n TemplateAction,\n} from '@backstage/plugin-scaffolder-node';\nimport {\n TemplateFilter,\n TemplateGlobal,\n TaskBroker,\n} from '@backstage/plugin-scaffolder-backend';\nimport { createBuiltinActions } from './scaffolder';\nimport { createRouter } from './service/router';\n\n/**\n * Catalog plugin options\n *\n * @alpha\n */\nexport type ScaffolderPluginOptions = {\n actions?: TemplateAction<any, any>[];\n taskWorkers?: number;\n taskBroker?: TaskBroker;\n additionalTemplateFilters?: Record<string, TemplateFilter>;\n additionalTemplateGlobals?: Record<string, TemplateGlobal>;\n};\n\nclass ScaffolderActionsExtensionPointImpl\n implements ScaffolderActionsExtensionPoint\n{\n #actions = new Array<TemplateAction<any, any>>();\n\n addActions(...actions: TemplateAction<any>[]): void {\n this.#actions.push(...actions);\n }\n\n get actions() {\n return this.#actions;\n }\n}\n\n/**\n * Catalog plugin\n *\n * @alpha\n */\nexport const scaffolderPlugin = createBackendPlugin(\n (options?: ScaffolderPluginOptions) => ({\n pluginId: 'scaffolder',\n register(env) {\n const actionsExtensions = new ScaffolderActionsExtensionPointImpl();\n\n env.registerExtensionPoint(\n scaffolderActionsExtensionPoint,\n actionsExtensions,\n );\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n reader: coreServices.urlReader,\n permissions: coreServices.permissions,\n database: coreServices.database,\n httpRouter: coreServices.httpRouter,\n catalogClient: catalogServiceRef,\n },\n async init({\n logger,\n config,\n reader,\n database,\n httpRouter,\n catalogClient,\n permissions,\n }) {\n const {\n additionalTemplateFilters,\n taskBroker,\n taskWorkers,\n additionalTemplateGlobals,\n } = options ?? {};\n const log = loggerToWinstonLogger(logger);\n\n const actions = options?.actions || [\n ...actionsExtensions.actions,\n ...createBuiltinActions({\n integrations: ScmIntegrations.fromConfig(config),\n catalogClient,\n reader,\n config,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n }),\n ];\n\n const actionIds = actions.map(action => action.id).join(', ');\n log.info(\n `Starting scaffolder with the following actions enabled ${actionIds}`,\n );\n\n const router = await createRouter({\n logger: log,\n config,\n database,\n catalogClient,\n reader,\n actions,\n taskBroker,\n taskWorkers,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n permissions,\n });\n httpRouter.use(router);\n },\n });\n },\n }),\n);\n"],"names":["createBackendModule","catalogProcessingExtensionPoint","ScaffolderEntitiesProcessor","createConditionExports","RESOURCE_TYPE_SCAFFOLDER_TEMPLATE","scaffolderTemplateRules","RESOURCE_TYPE_SCAFFOLDER_ACTION","scaffolderActionRules","createBackendPlugin","scaffolderActionsExtensionPoint","coreServices","catalogServiceRef","loggerToWinstonLogger","createBuiltinActions","ScmIntegrations","createRouter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAM,4BAA4BA,oCAAoB,CAAA;AAAA,EAC3D,QAAU,EAAA,YAAA;AAAA,EACV,QAAU,EAAA,cAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,OAAS,EAAAC,qCAAA;AAAA,OACX;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,OAAA,EAAW,EA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AAA,CAAA,IAAA;AAAA,YACF,0DAA0D,SAAS,CAAA,CAAA;AAAA,WACrE,CAAA;AAEA,UAAM,MAAA,MAAA,GAAS,MAAMC,wCAAa,CAAA;AAAA,YAChC,MAAQ,EAAA,GAAA;AAAA,YACR,MAAA;AAAA,YACA,QAAA;AAAA,YACA,aAAA;AAAA,YACA,MAAA;AAAA,YACA,OAAA;AAAA,YACA,UAAA;AAAA,YACA,WAAA;AAAA,YACA,yBAAA;AAAA,YACA,yBAAA;AAAA,YACA,WAAA;AAAA,WACD,CAAA,CAAA;AACD,UAAA,UAAA,CAAW,IAAI,MAAM,CAAA,CAAA;AAAA,SACvB;AAAA,OACD,CAAA,CAAA;AAAA,KACH;AAAA,GACF,CAAA;AACF;;;;;;;;;"}
1
+ {"version":3,"file":"alpha.cjs.js","sources":["../src/modules/catalogModuleTemplateKind.ts","../src/service/conditionExports.ts","../src/ScaffolderPlugin.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha';\nimport { ScaffolderEntitiesProcessor } from '../processor';\n\n/**\n * Registers support for the Template kind to the catalog backend plugin.\n *\n * @alpha\n */\nexport const catalogModuleTemplateKind = createBackendModule({\n moduleId: 'templateKind',\n pluginId: 'catalog',\n register(env) {\n env.registerInit({\n deps: {\n catalog: catalogProcessingExtensionPoint,\n },\n async init({ catalog }) {\n catalog.addProcessor(new ScaffolderEntitiesProcessor());\n },\n });\n },\n});\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,\n RESOURCE_TYPE_SCAFFOLDER_ACTION,\n} from '@backstage/plugin-scaffolder-common/alpha';\nimport { createConditionExports } from '@backstage/plugin-permission-node';\nimport { scaffolderTemplateRules, scaffolderActionRules } from './rules';\n\nconst templateConditionExports = createConditionExports({\n pluginId: 'scaffolder',\n resourceType: RESOURCE_TYPE_SCAFFOLDER_TEMPLATE,\n rules: scaffolderTemplateRules,\n});\n\nconst actionsConditionExports = createConditionExports({\n pluginId: 'scaffolder',\n resourceType: RESOURCE_TYPE_SCAFFOLDER_ACTION,\n rules: scaffolderActionRules,\n});\n\n/**\n * `createScaffolderTemplateConditionalDecision` can be used when authoring policies to\n * create conditional decisions. It requires a permission of type\n * `ResourcePermission<'scaffolder-template'>` to be passed as the first parameter.\n * It's recommended that you use the provided `isResourcePermission` and\n * `isPermission` helper methods to narrow the type of the permission passed to\n * the handle method as shown below.\n *\n * ```\n * // MyAuthorizationPolicy.ts\n * ...\n * import { createScaffolderPolicyDecision } from '@backstage/plugin-scaffolder-backend';\n * import { RESOURCE_TYPE_SCAFFOLDER_TEMPLATE } from '@backstage/plugin-scaffolder-common';\n *\n * class MyAuthorizationPolicy implements PermissionPolicy {\n * async handle(request, user) {\n * ...\n *\n * if (isResourcePermission(request.permission, RESOURCE_TYPE_SCAFFOLDER_TEMPLATE)) {\n * return createScaffolderConditionalDecision(\n * request.permission,\n * { anyOf: [...insert conditions here...] }\n * );\n * }\n *\n * ...\n * }\n *\n * ```\n *\n * @alpha\n */\nexport const createScaffolderTemplateConditionalDecision =\n templateConditionExports.createConditionalDecision;\n\n/**\n * These conditions are used when creating conditional decisions for scaffolder\n * templates that are returned by authorization policies.\n *\n * @alpha\n */\nexport const scaffolderTemplateConditions = templateConditionExports.conditions;\n\n/**\n * @alpha\n */\nexport const createScaffolderActionConditionalDecision =\n actionsConditionExports.createConditionalDecision;\n\n/**\n *\n * These conditions are used when creating conditional decisions for scaffolder\n * actions that are returned by authorization policies.\n *\n * @alpha\n */\nexport const scaffolderActionConditions = actionsConditionExports.conditions;\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';\nimport {\n scaffolderActionsExtensionPoint,\n scaffolderTaskBrokerExtensionPoint,\n scaffolderTemplatingExtensionPoint,\n TaskBroker,\n TemplateAction,\n TemplateFilter,\n TemplateGlobal,\n} from '@backstage/plugin-scaffolder-node';\nimport { createBuiltinActions } from './scaffolder';\nimport { createRouter } from './service/router';\n\n/**\n * Scaffolder plugin\n *\n * @alpha\n */\nexport const scaffolderPlugin = createBackendPlugin({\n pluginId: 'scaffolder',\n register(env) {\n const addedActions = new Array<TemplateAction<any, any>>();\n env.registerExtensionPoint(scaffolderActionsExtensionPoint, {\n addActions(...newActions: TemplateAction<any>[]) {\n addedActions.push(...newActions);\n },\n });\n\n let taskBroker: TaskBroker | undefined;\n env.registerExtensionPoint(scaffolderTaskBrokerExtensionPoint, {\n setTaskBroker(newTaskBroker) {\n if (taskBroker) {\n throw new Error('Task broker may only be set once');\n }\n taskBroker = newTaskBroker;\n },\n });\n\n const additionalTemplateFilters: Record<string, TemplateFilter> = {};\n const additionalTemplateGlobals: Record<string, TemplateGlobal> = {};\n env.registerExtensionPoint(scaffolderTemplatingExtensionPoint, {\n addTemplateFilters(newFilters) {\n Object.assign(additionalTemplateFilters, newFilters);\n },\n addTemplateGlobals(newGlobals) {\n Object.assign(additionalTemplateGlobals, newGlobals);\n },\n });\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n reader: coreServices.urlReader,\n permissions: coreServices.permissions,\n database: coreServices.database,\n httpRouter: coreServices.httpRouter,\n catalogClient: catalogServiceRef,\n },\n async init({\n logger,\n config,\n reader,\n database,\n httpRouter,\n catalogClient,\n permissions,\n }) {\n const log = loggerToWinstonLogger(logger);\n\n const actions = [\n ...addedActions,\n ...createBuiltinActions({\n integrations: ScmIntegrations.fromConfig(config),\n catalogClient,\n reader,\n config,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n }),\n ];\n\n const actionIds = actions.map(action => action.id).join(', ');\n log.info(\n `Starting scaffolder with the following actions enabled ${actionIds}`,\n );\n\n const router = await createRouter({\n logger: log,\n config,\n database,\n catalogClient,\n reader,\n actions,\n taskBroker,\n additionalTemplateFilters,\n additionalTemplateGlobals,\n permissions,\n });\n httpRouter.use(router);\n },\n });\n },\n});\n"],"names":["createBackendModule","catalogProcessingExtensionPoint","ScaffolderEntitiesProcessor","createConditionExports","RESOURCE_TYPE_SCAFFOLDER_TEMPLATE","scaffolderTemplateRules","RESOURCE_TYPE_SCAFFOLDER_ACTION","scaffolderActionRules","createBackendPlugin","scaffolderActionsExtensionPoint","scaffolderTaskBrokerExtensionPoint","scaffolderTemplatingExtensionPoint","coreServices","catalogServiceRef","loggerToWinstonLogger","createBuiltinActions","ScmIntegrations","createRouter"],"mappings":";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M,OAAU,GAAA;AAAA,UACd,GAAG,YAAA;AAAA,UACH,GAAGC,gDAAqB,CAAA;AAAA,YACtB,YAAA,EAAcC,2BAAgB,CAAA,UAAA,CAAW,MAAM,CAAA;AAAA,YAC/C,aAAA;AAAA,YACA,MAAA;AAAA,YACA,MAAA;AAAA,YACA,yBAAA;AAAA,YACA,yBAAA;AAAA,WACD,CAAA;AAAA,SACH,CAAA;AAEA,QAAM,MAAA,SAAA,GAAY,QAAQ,GAAI,CAAA,CAAA,MAAA,KAAU,OAAO,EAAE,CAAA,CAAE,KAAK,IAAI,CAAA,CAAA;AAC5D,QAAI,GAAA,CAAA,IAAA;AAAA,UACF,0DAA0D,SAAS,CAAA,CAAA;AAAA,SACrE,CAAA;AAEA,QAAM,MAAA,MAAA,GAAS,MAAMC,wCAAa,CAAA;AAAA,UAChC,MAAQ,EAAA,GAAA;AAAA,UACR,MAAA;AAAA,UACA,QAAA;AAAA,UACA,aAAA;AAAA,UACA,MAAA;AAAA,UACA,OAAA;AAAA,UACA,UAAA;AAAA,UACA,yBAAA;AAAA,UACA,yBAAA;AAAA,UACA,WAAA;AAAA,SACD,CAAA,CAAA;AACD,QAAA,UAAA,CAAW,IAAI,MAAM,CAAA,CAAA;AAAA,OACvB;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;;;;;"}
package/dist/alpha.d.ts CHANGED
@@ -3,8 +3,6 @@ import * as _backstage_types from '@backstage/types';
3
3
  import * as _backstage_plugin_permission_node from '@backstage/plugin-permission-node';
4
4
  import * as _backstage_plugin_scaffolder_common from '@backstage/plugin-scaffolder-common';
5
5
  import * as _backstage_plugin_permission_common from '@backstage/plugin-permission-common';
6
- import { TemplateAction } from '@backstage/plugin-scaffolder-node';
7
- import { TaskBroker, TemplateFilter, TemplateGlobal } from '@backstage/plugin-scaffolder-backend';
8
6
 
9
7
  /**
10
8
  * Registers support for the Template kind to the catalog backend plugin.
@@ -99,22 +97,10 @@ declare const scaffolderActionConditions: _backstage_plugin_permission_node.Cond
99
97
  }>;
100
98
 
101
99
  /**
102
- * Catalog plugin options
100
+ * Scaffolder plugin
103
101
  *
104
102
  * @alpha
105
103
  */
106
- type ScaffolderPluginOptions = {
107
- actions?: TemplateAction<any, any>[];
108
- taskWorkers?: number;
109
- taskBroker?: TaskBroker;
110
- additionalTemplateFilters?: Record<string, TemplateFilter>;
111
- additionalTemplateGlobals?: Record<string, TemplateGlobal>;
112
- };
113
- /**
114
- * Catalog plugin
115
- *
116
- * @alpha
117
- */
118
- declare const scaffolderPlugin: (options?: ScaffolderPluginOptions | undefined) => _backstage_backend_plugin_api.BackendFeature;
104
+ declare const scaffolderPlugin: () => _backstage_backend_plugin_api.BackendFeature;
119
105
 
120
- export { ScaffolderPluginOptions, catalogModuleTemplateKind, createScaffolderActionConditionalDecision, createScaffolderTemplateConditionalDecision, scaffolderActionConditions, scaffolderPlugin, scaffolderTemplateConditions };
106
+ export { catalogModuleTemplateKind, createScaffolderActionConditionalDecision, createScaffolderTemplateConditionalDecision, scaffolderActionConditions, scaffolderPlugin, scaffolderTemplateConditions };