Merge pull request #25361 from johnphilip283/add-publisher-extension-point

TechDocs: Add publisher extension point
This commit is contained in:
John Philip
2024-06-26 10:45:27 -04:00
committed by GitHub
9 changed files with 170 additions and 11 deletions
+14
View File
@@ -29,11 +29,14 @@ import {
PreparerBase,
Preparers,
Publisher,
PublisherBase,
PublisherType,
RemoteProtocol,
techdocsBuildsExtensionPoint,
TechdocsGenerator,
techdocsGeneratorExtensionPoint,
techdocsPreparerExtensionPoint,
techdocsPublisherExtensionPoint,
} from '@backstage/plugin-techdocs-node';
import { createRouter } from '@backstage/plugin-techdocs-backend';
import * as winston from 'winston';
@@ -85,6 +88,16 @@ export const techdocsPlugin = createBackendPlugin({
},
});
let customTechdocsPublisher: PublisherBase | undefined;
env.registerExtensionPoint(techdocsPublisherExtensionPoint, {
registerPublisher(type: PublisherType, publisher: PublisherBase) {
if (customTechdocsPublisher) {
throw new Error(`Publisher for type ${type} is already registered`);
}
customTechdocsPublisher = publisher;
},
});
env.registerInit({
deps: {
config: coreServices.rootConfig,
@@ -128,6 +141,7 @@ export const techdocsPlugin = createBackendPlugin({
const publisher = await Publisher.fromConfig(config, {
logger: winstonLogger,
discovery: discovery,
customPublisher: customTechdocsPublisher,
});
// checks if the publisher is working and logs the result