feat(techdocs): add extension for setting build strategy

Signed-off-by: Phil Kuang <pkuang@factset.com>
This commit is contained in:
Phil Kuang
2023-10-12 18:56:45 -04:00
parent b2817daf0c
commit 67cff7b06f
15 changed files with 119 additions and 43 deletions
+36
View File
@@ -0,0 +1,36 @@
/*
* 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 { createExtensionPoint } from '@backstage/backend-plugin-api';
import { DocsBuildStrategy } from './techdocsTypes';
/**
* Extension point type for setting a custom build strategy.
*
* @public
*/
export interface TechdocsBuildStrategyExtensionPoint {
setBuildStrategy(buildStrategy: DocsBuildStrategy): void;
}
/**
* Extension point for setting a custom build strategy.
*
* @public
*/
export const techdocsBuildStrategyExtensionPoint =
createExtensionPoint<TechdocsBuildStrategyExtensionPoint>({
id: 'techdocs.buildStrategy',
});
+4
View File
@@ -23,3 +23,7 @@
export * from './stages';
export * from './helpers';
export * from './techdocsTypes';
export {
techdocsBuildStrategyExtensionPoint,
type TechdocsBuildStrategyExtensionPoint,
} from './extensions';
@@ -14,6 +14,7 @@
* limitations under the License.
*/
import { Entity } from '@backstage/catalog-model';
import { IndexableDocument } from '@backstage/plugin-search-common';
/**
@@ -46,3 +47,21 @@ export interface TechDocsDocument extends IndexableDocument {
*/
path: string;
}
/**
* Parameters passed to the shouldBuild method on the DocsBuildStrategy interface
*
* @public
*/
export type ShouldBuildParameters = {
entity: Entity;
};
/**
* A strategy for when to build TechDocs locally, and when to skip building TechDocs (allowing for an external build)
*
* @public
*/
export interface DocsBuildStrategy {
shouldBuild(params: ShouldBuildParameters): Promise<boolean>;
}