@backstage/plugin-scaffolder-backend 1.15.2-next.2 → 1.16.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.
- package/CHANGELOG.md +49 -0
- package/alpha/package.json +1 -1
- package/config.d.ts +9 -0
- package/dist/alpha.cjs.js +77 -92
- package/dist/alpha.cjs.js.map +1 -1
- package/dist/alpha.d.ts +3 -17
- package/dist/cjs/{ScaffolderEntitiesProcessor-82f18a18.cjs.js → ScaffolderEntitiesProcessor-4b7489dd.cjs.js} +205 -72
- package/dist/cjs/ScaffolderEntitiesProcessor-4b7489dd.cjs.js.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +32 -66
- package/package.json +14 -14
- package/dist/cjs/ScaffolderEntitiesProcessor-82f18a18.cjs.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend
|
|
2
2
|
|
|
3
|
+
## 1.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e514aac3eac0: Introduce `each` property on action steps, allowing them to be ran repeatedly.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 629cbd194a87: Use `coreServices.rootConfig` instead of `coreService.config`
|
|
12
|
+
- 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`.
|
|
13
|
+
- 33c76caef72a: Added examples for the `fs:delete` and `fs:rename` actions
|
|
14
|
+
- e07a4914f621: Deprecated the following type exports, which have been moved to `@backstage/plugin-scaffolder-node` instead:
|
|
15
|
+
|
|
16
|
+
- `TemplateFilter`
|
|
17
|
+
- `TemplateGlobal`
|
|
18
|
+
- `TaskStatus`
|
|
19
|
+
- `TaskCompletionState`
|
|
20
|
+
- `SerializedTask`
|
|
21
|
+
- `TaskEventType`
|
|
22
|
+
- `SerializedTaskEvent`
|
|
23
|
+
- `TaskBrokerDispatchResult`
|
|
24
|
+
- `TaskBrokerDispatchOptions`
|
|
25
|
+
- `TaskContext`
|
|
26
|
+
- `TaskBroker`
|
|
27
|
+
|
|
28
|
+
- 0b1d775be05b: Adds examples to a few scaffolder actions.
|
|
29
|
+
- 88bc6e27a213: The `concurrentTasksLimit` option can now be configured via static configuration as well. Setting it to 0 will now also disable the task worker.
|
|
30
|
+
- 0f873325068d: Add examples for `github:repo:create` and `github:repo:push` scaffolder actions.
|
|
31
|
+
- 5c28ebc79fd6: Updated dependency `esbuild` to `^0.19.0`.
|
|
32
|
+
- 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.
|
|
33
|
+
- Updated dependencies
|
|
34
|
+
- @backstage/backend-common@0.19.2
|
|
35
|
+
- @backstage/plugin-catalog-backend@1.12.0
|
|
36
|
+
- @backstage/backend-plugin-api@0.6.0
|
|
37
|
+
- @backstage/plugin-scaffolder-node@0.2.0
|
|
38
|
+
- @backstage/plugin-catalog-node@1.4.1
|
|
39
|
+
- @backstage/plugin-auth-node@0.2.17
|
|
40
|
+
- @backstage/integration@1.6.0
|
|
41
|
+
- @backstage/backend-tasks@0.5.5
|
|
42
|
+
- @backstage/plugin-scaffolder-common@1.4.0
|
|
43
|
+
- @backstage/plugin-permission-node@0.7.11
|
|
44
|
+
- @backstage/catalog-client@1.4.3
|
|
45
|
+
- @backstage/catalog-model@1.4.1
|
|
46
|
+
- @backstage/config@1.0.8
|
|
47
|
+
- @backstage/errors@1.2.1
|
|
48
|
+
- @backstage/types@1.1.0
|
|
49
|
+
- @backstage/plugin-catalog-common@1.0.15
|
|
50
|
+
- @backstage/plugin-permission-common@0.7.7
|
|
51
|
+
|
|
3
52
|
## 1.15.2-next.2
|
|
4
53
|
|
|
5
54
|
### Patch Changes
|
package/alpha/package.json
CHANGED
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-
|
|
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');
|
|
@@ -78,101 +78,86 @@ const scaffolderTemplateConditions = templateConditionExports.conditions;
|
|
|
78
78
|
const createScaffolderActionConditionalDecision = actionsConditionExports.createConditionalDecision;
|
|
79
79
|
const scaffolderActionConditions = actionsConditionExports.conditions;
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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;
|
package/dist/alpha.cjs.js.map
CHANGED
|
@@ -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,EAAA;AACtB,QAAQ,OAAA,CAAA,YAAA,CAAa,IAAIC,uDAAA,EAA6B,CAAA,CAAA;AAAA,OACxD;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;ACfD,MAAM,2BAA2BC,2CAAu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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: '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 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAM,4BAA4BA,oCAAoB,CAAA;AAAA,EAC3D,QAAU,EAAA,YAAA;AAAA,EACV,QAAU,EAAA,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A;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
|
-
*
|
|
100
|
+
* Scaffolder plugin
|
|
103
101
|
*
|
|
104
102
|
* @alpha
|
|
105
103
|
*/
|
|
106
|
-
|
|
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 {
|
|
106
|
+
export { catalogModuleTemplateKind, createScaffolderActionConditionalDecision, createScaffolderTemplateConditionalDecision, scaffolderActionConditions, scaffolderPlugin, scaffolderTemplateConditions };
|