diff --git a/packages/backend/src/next/index.ts b/packages/backend/src/next/index.ts index 96b36e3e03..9deab2feeb 100644 --- a/packages/backend/src/next/index.ts +++ b/packages/backend/src/next/index.ts @@ -15,29 +15,8 @@ */ import { createBackend } from '@backstage/backend-app-api'; -// import { createBackendModule } from '@backstage/backend-plugin-api'; -import { - catalogPlugin, - // catalogProcessingInitApiRef, -} from '@backstage/plugin-catalog-backend'; -// import { ScaffolderEntitiesProcessor } from '@backstage/plugin-scaffolder-backend'; - -// export const scaffolderCatalogExtension = createBackendModule({ -// moduleId: 'scaffolder.extention', -// pluginId: 'catalog', -// register(env) { -// env.registerInit({ -// deps: { -// catalogProcessingInitApi: catalogProcessingInitApiRef, -// }, -// async init({ catalogProcessingInitApi }) { -// catalogProcessingInitApi.addProcessor( -// new ScaffolderEntitiesProcessor(), -// ); -// }, -// }); -// }, -// }); +import { catalogPlugin } from '@backstage/plugin-catalog-backend'; +import { scaffolderCatalogExtension } from '@backstage/plugin-scaffolder-backend'; // export const appPlugin = createBackendPlugin({ // id: 'app', @@ -68,5 +47,5 @@ const backend = createBackend({ }); backend.add(catalogPlugin({})); -// backend.add(scaffolderCatalogExtension({})); +backend.add(scaffolderCatalogExtension({})); backend.start(); diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index 2053f01e39..672b853f3b 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -5,6 +5,7 @@ ```ts /// +import { BackendRegistrable } from '@backstage/backend-plugin-api'; import { CatalogApi } from '@backstage/catalog-client'; import { CatalogProcessor } from '@backstage/plugin-catalog-backend'; import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend'; @@ -543,6 +544,11 @@ export type RunCommandOptions = { logStream?: Writable; }; +// @alpha +export const scaffolderCatalogExtension: ( + option: unknown, +) => BackendRegistrable; + // @public (undocumented) export class ScaffolderEntitiesProcessor implements CatalogProcessor { // (undocumented) diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json index a1bb552435..f2fabad69d 100644 --- a/plugins/scaffolder-backend/package.json +++ b/plugins/scaffolder-backend/package.json @@ -9,7 +9,8 @@ "publishConfig": { "access": "public", "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "types": "dist/index.d.ts", + "alphaTypes": "dist/index.alpha.d.ts" }, "backstage": { "role": "backend-plugin" @@ -25,7 +26,7 @@ ], "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build", + "build": "backstage-cli package build --experimental-type-build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -42,6 +43,8 @@ "@backstage/integration": "^1.2.2-next.2", "@backstage/plugin-catalog-backend": "^1.2.1-next.2", "@backstage/plugin-scaffolder-common": "^1.1.2-next.0", + "@backstage/backend-plugin-api": "^0.0.0", + "@backstage/plugin-catalog-node": "^0.0.0", "@backstage/types": "^1.0.0", "@gitbeaker/core": "^35.6.0", "@gitbeaker/node": "^35.1.0", @@ -93,6 +96,7 @@ "yaml": "^1.10.0" }, "files": [ + "alpha", "dist", "migrations", "config.d.ts", diff --git a/plugins/scaffolder-backend/src/extension/ScaffolderCatalogExtension.ts b/plugins/scaffolder-backend/src/extension/ScaffolderCatalogExtension.ts new file mode 100644 index 0000000000..9ca140a952 --- /dev/null +++ b/plugins/scaffolder-backend/src/extension/ScaffolderCatalogExtension.ts @@ -0,0 +1,39 @@ +/* + * Copyright 2022 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { createBackendModule } from '@backstage/backend-plugin-api'; +import { catalogProcessingExtentionPoint } from '@backstage/plugin-catalog-node'; +import { ScaffolderEntitiesProcessor } from '../processor'; + +/** + * @alpha + * Registers the ScaffolderEntitiesProcessor with the catalog processing extension point. + */ +export const scaffolderCatalogExtension = createBackendModule({ + moduleId: 'scaffolder.extention', + pluginId: 'catalog', + register(env) { + env.registerInit({ + deps: { + catalogProcessingExtensionPoint: catalogProcessingExtentionPoint, + }, + async init({ catalogProcessingExtensionPoint }) { + catalogProcessingExtensionPoint.addProcessor( + new ScaffolderEntitiesProcessor(), + ); + }, + }); + }, +}); diff --git a/plugins/scaffolder-backend/src/extension/index.ts b/plugins/scaffolder-backend/src/extension/index.ts new file mode 100644 index 0000000000..672e29e2ee --- /dev/null +++ b/plugins/scaffolder-backend/src/extension/index.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2022 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export { scaffolderCatalogExtension } from './ScaffolderCatalogExtension'; diff --git a/plugins/scaffolder-backend/src/index.ts b/plugins/scaffolder-backend/src/index.ts index 5978b6389b..a1032449d5 100644 --- a/plugins/scaffolder-backend/src/index.ts +++ b/plugins/scaffolder-backend/src/index.ts @@ -24,3 +24,4 @@ export * from './scaffolder'; export * from './service/router'; export * from './lib'; export * from './processor'; +export * from './extension';