refactor(techdocs): deprecate ShouldBuildParameters type
Signed-off-by: Phil Kuang <pkuang@factset.com>
This commit is contained in:
@@ -3,4 +3,4 @@
|
||||
'@backstage/plugin-techdocs-node': minor
|
||||
---
|
||||
|
||||
Expose an extension point to set a custom build strategy and move `DocsBuildStrategy` and `ShouldBuildParameters` types to `@backstage/plugin-techdocs-node`
|
||||
Expose an extension point to set a custom build strategy. Also move `DocsBuildStrategy` type to `@backstage/plugin-techdocs-node` and deprecate `ShouldBuildParameters` type.
|
||||
|
||||
@@ -8,6 +8,7 @@ import { CatalogClient } from '@backstage/catalog-client';
|
||||
import { Config } from '@backstage/config';
|
||||
import { DefaultTechDocsCollatorFactory as DefaultTechDocsCollatorFactory_2 } from '@backstage/plugin-search-backend-module-techdocs';
|
||||
import { DocsBuildStrategy as DocsBuildStrategy_2 } from '@backstage/plugin-techdocs-node';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import express from 'express';
|
||||
import { GeneratorBuilder } from '@backstage/plugin-techdocs-node';
|
||||
import { Knex } from 'knex';
|
||||
@@ -17,7 +18,6 @@ import { PluginCacheManager } from '@backstage/backend-common';
|
||||
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
||||
import { PreparerBuilder } from '@backstage/plugin-techdocs-node';
|
||||
import { PublisherBase } from '@backstage/plugin-techdocs-node';
|
||||
import { ShouldBuildParameters as ShouldBuildParameters_2 } from '@backstage/plugin-techdocs-node';
|
||||
import type { TechDocsCollatorFactoryOptions as TechDocsCollatorFactoryOptions_2 } from '@backstage/plugin-search-backend-module-techdocs';
|
||||
import { TechDocsDocument as TechDocsDocument_2 } from '@backstage/plugin-techdocs-node';
|
||||
import { TokenManager } from '@backstage/backend-common';
|
||||
@@ -85,7 +85,9 @@ export type RouterOptions =
|
||||
| OutOfTheBoxDeploymentOptions;
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
export type ShouldBuildParameters = ShouldBuildParameters_2;
|
||||
export type ShouldBuildParameters = {
|
||||
entity: Entity;
|
||||
};
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
export type TechDocsCollatorFactoryOptions = TechDocsCollatorFactoryOptions_2;
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
* @packageDocumentation
|
||||
*/
|
||||
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import {
|
||||
DocsBuildStrategy as _DocsBuildStrategy,
|
||||
ShouldBuildParameters as _ShouldBuildParameters,
|
||||
TechDocsDocument as _TechDocsDocument,
|
||||
} from '@backstage/plugin-techdocs-node';
|
||||
|
||||
@@ -49,9 +49,11 @@ export type {
|
||||
export type DocsBuildStrategy = _DocsBuildStrategy;
|
||||
/**
|
||||
* @public
|
||||
* @deprecated import from `@backstage/plugin-techdocs-node` instead
|
||||
* @deprecated use direct type definition instead
|
||||
*/
|
||||
export type ShouldBuildParameters = _ShouldBuildParameters;
|
||||
export type ShouldBuildParameters = {
|
||||
entity: Entity;
|
||||
};
|
||||
/**
|
||||
* @public
|
||||
* @deprecated import from `@backstage/plugin-techdocs-node` instead
|
||||
|
||||
@@ -13,11 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { Config } from '@backstage/config';
|
||||
import {
|
||||
DocsBuildStrategy,
|
||||
ShouldBuildParameters,
|
||||
} from '@backstage/plugin-techdocs-node';
|
||||
import { DocsBuildStrategy } from '@backstage/plugin-techdocs-node';
|
||||
|
||||
export class DefaultDocsBuildStrategy implements DocsBuildStrategy {
|
||||
private readonly config: Config;
|
||||
@@ -30,7 +28,7 @@ export class DefaultDocsBuildStrategy implements DocsBuildStrategy {
|
||||
return new DefaultDocsBuildStrategy(config);
|
||||
}
|
||||
|
||||
async shouldBuild(_: ShouldBuildParameters): Promise<boolean> {
|
||||
async shouldBuild(_: { entity: Entity }): Promise<boolean> {
|
||||
return this.config.getString('techdocs.builder') === 'local';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export class DirectoryPreparer implements PreparerBase {
|
||||
// @public
|
||||
export interface DocsBuildStrategy {
|
||||
// (undocumented)
|
||||
shouldBuild(params: ShouldBuildParameters): Promise<boolean>;
|
||||
shouldBuild(params: { entity: Entity }): Promise<boolean>;
|
||||
}
|
||||
|
||||
// @public
|
||||
@@ -233,11 +233,6 @@ export type ReadinessResponse = {
|
||||
// @public
|
||||
export type RemoteProtocol = 'url' | 'dir';
|
||||
|
||||
// @public
|
||||
export type ShouldBuildParameters = {
|
||||
entity: Entity;
|
||||
};
|
||||
|
||||
// @public
|
||||
export type SupportedGeneratorKey = 'techdocs' | string;
|
||||
|
||||
|
||||
@@ -48,20 +48,11 @@ 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>;
|
||||
shouldBuild(params: { entity: Entity }): Promise<boolean>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user