expose the techdocs-backend plugin using the new system

Signed-off-by: Oleg S <97077423+RobotSail@users.noreply.github.com>
This commit is contained in:
Oleg S
2023-03-06 17:00:01 -05:00
parent d2dc5b01f4
commit 92b495328b
8 changed files with 112 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/plugin-techdocs-backend': minor
'example-backend-next': minor
---
Expose the techdocs-backend plugin using the new plugin system
+1
View File
@@ -29,6 +29,7 @@
"@backstage/plugin-app-backend": "workspace:^",
"@backstage/plugin-catalog-backend": "workspace:^",
"@backstage/plugin-scaffolder-backend": "workspace:^",
"@backstage/plugin-techdocs-backend": "workspace:^",
"@backstage/plugin-todo-backend": "workspace:^"
},
"devDependencies": {
+2
View File
@@ -19,6 +19,7 @@ import { catalogModuleTemplateKind } from '@backstage/plugin-scaffolder-backend/
import { createBackend } from '@backstage/backend-defaults';
import { appPlugin } from '@backstage/plugin-app-backend/alpha';
import { todoPlugin } from '@backstage/plugin-todo-backend';
import { techdocsPlugin } from '@backstage/plugin-techdocs-backend';
const backend = createBackend();
@@ -26,4 +27,5 @@ backend.add(catalogPlugin());
backend.add(catalogModuleTemplateKind());
backend.add(appPlugin({ appPackageName: 'example-app' }));
backend.add(todoPlugin());
backend.add(techdocsPlugin());
backend.start();
+4
View File
@@ -5,6 +5,7 @@
```ts
/// <reference types="node" />
import { BackendFeature } from '@backstage/backend-plugin-api';
import { CatalogApi } from '@backstage/catalog-client';
import { CatalogClient } from '@backstage/catalog-client';
import { Config } from '@backstage/config';
@@ -129,5 +130,8 @@ export type TechDocsCollatorOptions = {
export { TechDocsDocument };
// @public
export const techdocsPlugin: () => BackendFeature;
export * from '@backstage/plugin-techdocs-node';
```
+1
View File
@@ -34,6 +34,7 @@
},
"dependencies": {
"@backstage/backend-common": "workspace:^",
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/catalog-client": "workspace:^",
"@backstage/catalog-model": "workspace:^",
"@backstage/config": "workspace:^",
+1
View File
@@ -37,6 +37,7 @@ export type {
TechDocsCollatorFactoryOptions,
TechDocsCollatorOptions,
} from './search';
export { techdocsPlugin } from './plugin';
/**
* @deprecated Use directly from @backstage/plugin-techdocs-node
+95
View File
@@ -0,0 +1,95 @@
/*
* Copyright 2023 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 {
DockerContainerRunner,
loggerToWinstonLogger,
cacheToPluginCacheManager,
} from '@backstage/backend-common';
import {
coreServices,
createBackendPlugin,
} from '@backstage/backend-plugin-api';
import {
Preparers,
Generators,
Publisher,
} from '@backstage/plugin-techdocs-node';
import Docker from 'dockerode';
import { createRouter } from './service';
/**
* The TechDocs plugin is responsible for serving and building documentation for any entity.
* @public
*/
export const techdocsPlugin = createBackendPlugin({
pluginId: 'techdocs-backend',
register(env) {
env.registerInit({
deps: {
config: coreServices.config,
logger: coreServices.logger,
urlReader: coreServices.urlReader,
http: coreServices.httpRouter,
discovery: coreServices.discovery,
cache: coreServices.cache,
},
async init({ config, logger, urlReader, http, discovery, cache }) {
const winstonLogger = loggerToWinstonLogger(logger);
// Preparers are responsible for fetching source files for documentation.
const preparers = await Preparers.fromConfig(config, {
reader: urlReader,
logger: winstonLogger,
});
// Docker client (conditionally) used by the generators, based on techdocs.generators config.
const dockerClient = new Docker();
const containerRunner = new DockerContainerRunner({ dockerClient });
// Generators are used for generating documentation sites.
const generators = await Generators.fromConfig(config, {
logger: winstonLogger,
containerRunner,
});
// Publisher is used for
// 1. Publishing generated files to storage
// 2. Fetching files from storage and passing them to TechDocs frontend.
const publisher = await Publisher.fromConfig(config, {
logger: winstonLogger,
discovery: discovery,
});
// checks if the publisher is working and logs the result
await publisher.getReadiness();
const cacheManager = cacheToPluginCacheManager(cache);
http.use(
await createRouter({
logger: winstonLogger,
cache: cacheManager,
preparers,
generators,
publisher,
config,
discovery,
}),
);
},
});
},
});
+2
View File
@@ -8538,6 +8538,7 @@ __metadata:
resolution: "@backstage/plugin-techdocs-backend@workspace:plugins/techdocs-backend"
dependencies:
"@backstage/backend-common": "workspace:^"
"@backstage/backend-plugin-api": "workspace:^"
"@backstage/backend-test-utils": "workspace:^"
"@backstage/catalog-client": "workspace:^"
"@backstage/catalog-model": "workspace:^"
@@ -22870,6 +22871,7 @@ __metadata:
"@backstage/plugin-app-backend": "workspace:^"
"@backstage/plugin-catalog-backend": "workspace:^"
"@backstage/plugin-scaffolder-backend": "workspace:^"
"@backstage/plugin-techdocs-backend": "workspace:^"
"@backstage/plugin-todo-backend": "workspace:^"
languageName: unknown
linkType: soft