From 7cb5788e9ce94ec03d9304902efa006bc9f94202 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 14 Mar 2022 13:39:16 +0100 Subject: [PATCH 1/9] clean up deprecations of techdocs plugin Signed-off-by: Emma Indal --- docs/features/techdocs/configuration.md | 5 -- plugins/techdocs/api-report.md | 23 +----- plugins/techdocs/config.d.ts | 7 -- plugins/techdocs/src/api.ts | 6 -- plugins/techdocs/src/client.ts | 10 +-- .../components/LegacyTechDocsHome.test.tsx | 76 ------------------ .../home/components/LegacyTechDocsHome.tsx | 58 -------------- .../reader/components/LegacyTechDocsPage.tsx | 80 ------------------- .../reader/components/TechDocsReaderPage.tsx | 16 +--- .../components/TechDocsReaderPageHeader.tsx | 13 --- .../techdocs/src/reader/components/index.ts | 2 - .../TechDocsSearchResultListItem.tsx | 6 -- 12 files changed, 6 insertions(+), 296 deletions(-) delete mode 100644 plugins/techdocs/src/home/components/LegacyTechDocsHome.test.tsx delete mode 100644 plugins/techdocs/src/home/components/LegacyTechDocsHome.tsx delete mode 100644 plugins/techdocs/src/reader/components/LegacyTechDocsPage.tsx diff --git a/docs/features/techdocs/configuration.md b/docs/features/techdocs/configuration.md index 3edc55574f..d16e9142dc 100644 --- a/docs/features/techdocs/configuration.md +++ b/docs/features/techdocs/configuration.md @@ -161,11 +161,6 @@ techdocs: # default value is 1000 readTimeout: 500 - # (Optional and Legacy) TechDocs makes API calls to techdocs-backend using this URL. e.g. get docs of an entity, get metadata, etc. - # You don't have to specify this anymore. - - requestUrl: http://localhost:7007/api/techdocs - # (Optional and Legacy) Just another route in techdocs-backend where TechDocs requests the static files from. This URL uses an HTTP middleware # to serve files from either a local directory or an External storage provider. # You don't have to specify this anymore. diff --git a/plugins/techdocs/api-report.md b/plugins/techdocs/api-report.md index f7ef6e984a..e6f9d463ed 100644 --- a/plugins/techdocs/api-report.md +++ b/plugins/techdocs/api-report.md @@ -41,11 +41,6 @@ export type DocsCardGridProps = { entities: Entity[] | undefined; }; -// @public @deprecated (undocumented) -export const DocsResultListItem: ( - props: TechDocsSearchResultListItemProps, -) => JSX.Element; - // @public export const DocsTable: { (props: DocsTableProps): JSX.Element | null; @@ -185,6 +180,7 @@ export type TabsConfig = TabConfig[]; // @public export interface TechDocsApi { + // (undocumented) getApiOrigin(): Promise; // (undocumented) getEntityMetadata( @@ -243,23 +239,9 @@ export type TechDocsMetadata = { site_description: string; }; -// @public @deprecated (undocumented) -export const TechDocsPage: (props: TechDocsReaderPageProps) => JSX.Element; - // @public export const TechdocsPage: () => JSX.Element; -// @public @deprecated (undocumented) -export const TechDocsPageHeader: ( - props: TechDocsReaderPageHeaderProps, -) => JSX.Element; - -// @public @deprecated (undocumented) -export type TechDocsPageHeaderProps = TechDocsReaderPageHeaderProps; - -// @public @deprecated (undocumented) -export type TechDocsPageRenderFunction = TechDocsReaderPageRenderFunction; - // @public export const TechDocsPageWrapper: ( props: TechDocsPageWrapperProps, @@ -292,7 +274,7 @@ export { techdocsPlugin }; // @public export const TechDocsReaderPage: ( props: TechDocsReaderPageProps, -) => JSX.Element; +) => JSX.Element | null; // @public export const TechDocsReaderPageHeader: ( @@ -348,6 +330,7 @@ export type TechDocsSearchResultListItemProps = { // @public export interface TechDocsStorageApi { + // (undocumented) getApiOrigin(): Promise; // (undocumented) getBaseUrl( diff --git a/plugins/techdocs/config.d.ts b/plugins/techdocs/config.d.ts index 5274a31ed0..82ae8dd87a 100644 --- a/plugins/techdocs/config.d.ts +++ b/plugins/techdocs/config.d.ts @@ -33,13 +33,6 @@ export interface Config { */ legacyUseCaseSensitiveTripletPaths?: boolean; - /** - * @example http://localhost:7007/api/techdocs - * @visibility frontend - * @deprecated - */ - requestUrl?: string; - sanitizer?: { /** * Allows iframe tag only for listed hosts diff --git a/plugins/techdocs/src/api.ts b/plugins/techdocs/src/api.ts index b349431b0d..51dd82e643 100644 --- a/plugins/techdocs/src/api.ts +++ b/plugins/techdocs/src/api.ts @@ -49,9 +49,6 @@ export type SyncResult = 'cached' | 'updated'; * @public */ export interface TechDocsStorageApi { - /** - * Set to techdocs.requestUrl as the URL for techdocs-backend API. - */ getApiOrigin(): Promise; getStorageUrl(): Promise; getBuilder(): Promise; @@ -73,9 +70,6 @@ export interface TechDocsStorageApi { * @public */ export interface TechDocsApi { - /** - * Set to techdocs.requestUrl as the URL for techdocs-backend API. - */ getApiOrigin(): Promise; getTechDocsMetadata(entityId: CompoundEntityRef): Promise; getEntityMetadata( diff --git a/plugins/techdocs/src/client.ts b/plugins/techdocs/src/client.ts index f260f00547..69a5a91efc 100644 --- a/plugins/techdocs/src/client.ts +++ b/plugins/techdocs/src/client.ts @@ -47,10 +47,7 @@ export class TechDocsClient implements TechDocsApi { } async getApiOrigin(): Promise { - return ( - this.configApi.getOptionalString('techdocs.requestUrl') ?? - (await this.discoveryApi.getBaseUrl('techdocs')) - ); + return await this.discoveryApi.getBaseUrl('techdocs'); } /** @@ -126,10 +123,7 @@ export class TechDocsStorageClient implements TechDocsStorageApi { } async getApiOrigin(): Promise { - return ( - this.configApi.getOptionalString('techdocs.requestUrl') ?? - (await this.discoveryApi.getBaseUrl('techdocs')) - ); + return await this.discoveryApi.getBaseUrl('techdocs'); } async getStorageUrl(): Promise { diff --git a/plugins/techdocs/src/home/components/LegacyTechDocsHome.test.tsx b/plugins/techdocs/src/home/components/LegacyTechDocsHome.test.tsx deleted file mode 100644 index 4c33f69fb7..0000000000 --- a/plugins/techdocs/src/home/components/LegacyTechDocsHome.test.tsx +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2021 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 { CatalogApi, catalogApiRef } from '@backstage/plugin-catalog-react'; -import { renderInTestApp, TestApiRegistry } from '@backstage/test-utils'; -import { screen } from '@testing-library/react'; -import React from 'react'; -import { LegacyTechDocsHome } from './LegacyTechDocsHome'; - -import { ApiProvider, ConfigReader } from '@backstage/core-app-api'; -import { ConfigApi, configApiRef } from '@backstage/core-plugin-api'; -import { rootDocsRouteRef } from '../../routes'; - -const mockCatalogApi = { - getEntityByRef: jest.fn(), - getEntities: async () => ({ - items: [ - { - apiVersion: 'version', - kind: 'User', - metadata: { - name: 'owned', - namespace: 'default', - }, - }, - ], - }), -} as Partial; - -describe('Legacy TechDocs Home', () => { - const configApi: ConfigApi = new ConfigReader({ - organization: { - name: 'My Company', - }, - }); - - const apiRegistry = TestApiRegistry.from( - [catalogApiRef, mockCatalogApi], - [configApiRef, configApi], - ); - - it('should render a TechDocs home page', async () => { - await renderInTestApp( - - - , - { - mountedRoutes: { - '/docs/:namespace/:kind/:name/*': rootDocsRouteRef, - }, - }, - ); - - // Header - expect(await screen.findByText('Documentation')).toBeInTheDocument(); - expect( - await screen.findByText(/Documentation available in My Company/i), - ).toBeInTheDocument(); - - // Explore Content - expect(await screen.findByTestId('docs-explore')).toBeDefined(); - }); -}); diff --git a/plugins/techdocs/src/home/components/LegacyTechDocsHome.tsx b/plugins/techdocs/src/home/components/LegacyTechDocsHome.tsx deleted file mode 100644 index 536c2c80c8..0000000000 --- a/plugins/techdocs/src/home/components/LegacyTechDocsHome.tsx +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2021 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 React from 'react'; -import { PanelType, TechDocsCustomHome } from './TechDocsCustomHome'; - -/** - * @deprecated Use {@link TechDocsCustomHome} instead. - */ -export const LegacyTechDocsHome = () => { - const tabsConfig = [ - { - label: 'Overview', - panels: [ - { - title: 'Overview', - description: - 'Explore your internal technical ecosystem through documentation.', - panelType: 'DocsCardGrid' as PanelType, - filterPredicate: () => true, - }, - // uncomment this if you would like to have a secondary panel with owned documents - // { - // title: 'Owned', - // description: 'Explore your owned internal documentation.', - // panelType: 'DocsCardGrid' as PanelType, - // filterPredicate: 'ownedByUser', - // }, - ], - }, - { - label: 'Owned Documents', - panels: [ - { - title: 'Owned documents', - description: 'Access your documentation.', - panelType: 'DocsTable' as PanelType, - // ownedByUser filters out entities owned by signed in user - filterPredicate: 'ownedByUser', - }, - ], - }, - ]; - return ; -}; diff --git a/plugins/techdocs/src/reader/components/LegacyTechDocsPage.tsx b/plugins/techdocs/src/reader/components/LegacyTechDocsPage.tsx deleted file mode 100644 index 4bfda57ace..0000000000 --- a/plugins/techdocs/src/reader/components/LegacyTechDocsPage.tsx +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2020 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 React, { useCallback, useState } from 'react'; -import { useParams } from 'react-router-dom'; -import useAsync from 'react-use/lib/useAsync'; -import { techdocsApiRef } from '../../api'; -import { TechDocsNotFound } from './TechDocsNotFound'; -import { useApi } from '@backstage/core-plugin-api'; -import { Page, Content } from '@backstage/core-components'; -import { Reader } from './Reader'; -import { TechDocsReaderPageHeader } from './TechDocsReaderPageHeader'; - -/** - * @deprecated Use {@link TechDocsReaderPage} instead. - */ -export const LegacyTechDocsPage = () => { - const [documentReady, setDocumentReady] = useState(false); - const { namespace, kind, name } = useParams(); - - const techdocsApi = useApi(techdocsApiRef); - - const { value: techdocsMetadataValue } = useAsync(() => { - if (documentReady) { - return techdocsApi.getTechDocsMetadata({ kind, namespace, name }); - } - - return Promise.resolve(undefined); - }, [kind, namespace, name, techdocsApi, documentReady]); - - const { value: entityMetadataValue, error: entityMetadataError } = - useAsync(() => { - return techdocsApi.getEntityMetadata({ kind, namespace, name }); - }, [kind, namespace, name, techdocsApi]); - - const onReady = useCallback(() => { - setDocumentReady(true); - }, [setDocumentReady]); - - if (entityMetadataError) { - return ; - } - - return ( - - - - - - - ); -}; diff --git a/plugins/techdocs/src/reader/components/TechDocsReaderPage.tsx b/plugins/techdocs/src/reader/components/TechDocsReaderPage.tsx index 184ab24b6d..ff44d429df 100644 --- a/plugins/techdocs/src/reader/components/TechDocsReaderPage.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsReaderPage.tsx @@ -19,7 +19,6 @@ import { useOutlet } from 'react-router'; import { useParams } from 'react-router-dom'; import useAsync from 'react-use/lib/useAsync'; import { techdocsApiRef } from '../../api'; -import { LegacyTechDocsPage } from './LegacyTechDocsPage'; import { TechDocsEntityMetadata, TechDocsMetadata } from '../../types'; import { CompoundEntityRef } from '@backstage/catalog-model'; import { useApi, useApp } from '@backstage/core-plugin-api'; @@ -79,7 +78,7 @@ export const TechDocsReaderPage = (props: TechDocsReaderPageProps) => { if (entityMetadataError) return ; - if (!children) return outlet || ; + if (!children) return outlet; return ( @@ -94,16 +93,3 @@ export const TechDocsReaderPage = (props: TechDocsReaderPageProps) => { ); }; - -/** - * @public - * @deprecated use {@link TechDocsReaderPage} instead - */ -export const TechDocsPage = TechDocsReaderPage; - -/** - * @public - * @deprecated use {@link TechDocsReaderPageRenderFunction} instead - */ - -export type TechDocsPageRenderFunction = TechDocsReaderPageRenderFunction; diff --git a/plugins/techdocs/src/reader/components/TechDocsReaderPageHeader.tsx b/plugins/techdocs/src/reader/components/TechDocsReaderPageHeader.tsx index 5867641c48..f6a3352e7d 100644 --- a/plugins/techdocs/src/reader/components/TechDocsReaderPageHeader.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsReaderPageHeader.tsx @@ -122,16 +122,3 @@ export const TechDocsReaderPageHeader = ( ); }; - -/** - * @public - * @deprecated use {@link TechDocsReaderPageHeader} instead - */ -export const TechDocsPageHeader = TechDocsReaderPageHeader; - -/** - * @public - * @deprecated use {@link TechDocsReaderPageHeader} instead - */ - -export type TechDocsPageHeaderProps = TechDocsReaderPageHeaderProps; diff --git a/plugins/techdocs/src/reader/components/index.ts b/plugins/techdocs/src/reader/components/index.ts index 3124a92f93..8e660767ad 100644 --- a/plugins/techdocs/src/reader/components/index.ts +++ b/plugins/techdocs/src/reader/components/index.ts @@ -17,10 +17,8 @@ export * from './Reader'; export type { TechDocsReaderPageProps, - TechDocsPageRenderFunction, TechDocsReaderPageRenderFunction, } from './TechDocsReaderPage'; -export { TechDocsPage } from './TechDocsReaderPage'; export * from './TechDocsReaderPageHeader'; export * from './TechDocsStateIndicator'; diff --git a/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.tsx b/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.tsx index 152fa2e3d3..db5751654d 100644 --- a/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.tsx +++ b/plugins/techdocs/src/search/components/TechDocsSearchResultListItem.tsx @@ -101,9 +101,3 @@ export const TechDocsSearchResultListItem = ( ); }; - -/** - * @public - * @deprecated use {@link TechDocsSearchResultListItem} instead - */ -export const DocsResultListItem = TechDocsSearchResultListItem; From cb4f0e4f07c7a7d18e4ec5ce9c2f10cca0bf3171 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 14 Mar 2022 14:03:24 +0100 Subject: [PATCH 2/9] clean up deprecations of techdocs-node plugin Signed-off-by: Emma Indal --- plugins/techdocs-node/api-report.md | 22 ++++++++----------- .../src/stages/prepare/dir.test.ts | 21 ++++++++---------- .../techdocs-node/src/stages/prepare/dir.ts | 15 ++++++++----- .../src/stages/prepare/preparers.ts | 7 +++--- .../techdocs-node/src/stages/prepare/url.ts | 11 +++++----- 5 files changed, 35 insertions(+), 41 deletions(-) diff --git a/plugins/techdocs-node/api-report.md b/plugins/techdocs-node/api-report.md index 4c88ab0fc0..a5446c77cd 100644 --- a/plugins/techdocs-node/api-report.md +++ b/plugins/techdocs-node/api-report.md @@ -11,7 +11,7 @@ import { ContainerRunner } from '@backstage/backend-common'; import { Entity } from '@backstage/catalog-model'; import express from 'express'; import { IndexableDocument } from '@backstage/plugin-search-common'; -import { Logger } from 'winston'; +import { Logger as Logger_2 } from 'winston'; import { PluginEndpointDiscovery } from '@backstage/backend-common'; import { ScmIntegrationRegistry } from '@backstage/integration'; import { UrlReader } from '@backstage/backend-common'; @@ -19,8 +19,6 @@ import { Writable } from 'stream'; // @public export class DirectoryPreparer implements PreparerBase { - // @deprecated - constructor(config: Config, _logger: Logger | null, reader: UrlReader); static fromConfig( config: Config, { logger, reader }: PreparerConfig, @@ -45,7 +43,7 @@ export type GeneratorBuilder = { // @public export type GeneratorOptions = { containerRunner: ContainerRunner; - logger: Logger; + logger: Logger_2; }; // @public @@ -54,7 +52,7 @@ export type GeneratorRunOptions = { outputDir: string; parsedLocationAnnotation?: ParsedLocationAnnotation; etag?: string; - logger: Logger; + logger: Logger_2; logStream?: Writable; }; @@ -63,7 +61,7 @@ export class Generators implements GeneratorBuilder { static fromConfig( config: Config, options: { - logger: Logger; + logger: Logger_2; containerRunner: ContainerRunner; }, ): Promise; @@ -78,7 +76,7 @@ export const getDocFilesFromRepository: ( opts?: | { etag?: string | undefined; - logger?: Logger | undefined; + logger?: Logger_2 | undefined; } | undefined, ) => Promise; @@ -120,13 +118,13 @@ export type PreparerBuilder = { // @public export type PreparerConfig = { - logger: Logger; + logger: Logger_2; reader: UrlReader; }; // @public export type PreparerOptions = { - logger?: Logger; + logger?: Logger_2; etag?: ETag; }; @@ -168,7 +166,7 @@ export interface PublisherBase { // @public export type PublisherFactory = { - logger: Logger; + logger: Logger_2; discovery: PluginEndpointDiscovery; }; @@ -216,7 +214,7 @@ export interface TechDocsDocument extends IndexableDocument { // @public export class TechdocsGenerator implements GeneratorBase { constructor(options: { - logger: Logger; + logger: Logger_2; containerRunner: ContainerRunner; config: Config; scmIntegrations: ScmIntegrationRegistry; @@ -250,8 +248,6 @@ export const transformDirLocation: ( // @public export class UrlPreparer implements PreparerBase { - // @deprecated - constructor(reader: UrlReader, logger: Logger); static fromConfig({ reader, logger }: PreparerConfig): UrlPreparer; prepare(entity: Entity, options?: PreparerOptions): Promise; } diff --git a/plugins/techdocs-node/src/stages/prepare/dir.test.ts b/plugins/techdocs-node/src/stages/prepare/dir.test.ts index 2bf3fe29fc..829c414ddb 100644 --- a/plugins/techdocs-node/src/stages/prepare/dir.test.ts +++ b/plugins/techdocs-node/src/stages/prepare/dir.test.ts @@ -52,11 +52,10 @@ const mockUrlReader: jest.Mocked = { describe('directory preparer', () => { it('should merge managed-by-location and techdocs-ref when techdocs-ref is relative', async () => { - const directoryPreparer = new DirectoryPreparer( - mockConfig, + const directoryPreparer = DirectoryPreparer.fromConfig(mockConfig, { logger, - mockUrlReader, - ); + reader: mockUrlReader, + }); const mockEntity = createMockEntity({ 'backstage.io/managed-by-location': @@ -69,11 +68,10 @@ describe('directory preparer', () => { }); it('should reject when techdocs-ref is absolute', async () => { - const directoryPreparer = new DirectoryPreparer( - mockConfig, + const directoryPreparer = DirectoryPreparer.fromConfig(mockConfig, { logger, - mockUrlReader, - ); + reader: mockUrlReader, + }); const mockEntity = createMockEntity({ 'backstage.io/managed-by-location': @@ -87,11 +85,10 @@ describe('directory preparer', () => { }); it('should reject when managed-by-location has an unknown type', async () => { - const directoryPreparer = new DirectoryPreparer( - mockConfig, + const directoryPreparer = DirectoryPreparer.fromConfig(mockConfig, { logger, - mockUrlReader, - ); + reader: mockUrlReader, + }); const mockEntity = createMockEntity({ 'backstage.io/managed-by-location': diff --git a/plugins/techdocs-node/src/stages/prepare/dir.ts b/plugins/techdocs-node/src/stages/prepare/dir.ts index 42bfa5b903..c0298c0dab 100644 --- a/plugins/techdocs-node/src/stages/prepare/dir.ts +++ b/plugins/techdocs-node/src/stages/prepare/dir.ts @@ -39,12 +39,6 @@ export class DirectoryPreparer implements PreparerBase { private readonly scmIntegrations: ScmIntegrationRegistry; private readonly reader: UrlReader; - /** @deprecated use static fromConfig method instead */ - constructor(config: Config, _logger: Logger | null, reader: UrlReader) { - this.reader = reader; - this.scmIntegrations = ScmIntegrations.fromConfig(config); - } - /** * Returns a directory preparer instance * @param config - A backstage config @@ -57,6 +51,15 @@ export class DirectoryPreparer implements PreparerBase { return new DirectoryPreparer(config, logger, reader); } + private constructor( + config: Config, + _logger: Logger | null, + reader: UrlReader, + ) { + this.reader = reader; + this.scmIntegrations = ScmIntegrations.fromConfig(config); + } + /** {@inheritDoc PreparerBase.prepare} */ async prepare( entity: Entity, diff --git a/plugins/techdocs-node/src/stages/prepare/preparers.ts b/plugins/techdocs-node/src/stages/prepare/preparers.ts index 575294e91a..a8c175125a 100644 --- a/plugins/techdocs-node/src/stages/prepare/preparers.ts +++ b/plugins/techdocs-node/src/stages/prepare/preparers.ts @@ -44,18 +44,17 @@ export class Preparers implements PreparerBuilder { ): Promise { const preparers = new Preparers(); - const urlPreparer = new UrlPreparer(reader, logger); + const urlPreparer = UrlPreparer.fromConfig({ reader, logger }); preparers.register('url', urlPreparer); /** * Dir preparer is a syntactic sugar for users to define techdocs-ref annotation. * When using dir preparer, the docs will be fetched using URL Reader. */ - const directoryPreparer = new DirectoryPreparer( - backstageConfig, + const directoryPreparer = DirectoryPreparer.fromConfig(backstageConfig, { logger, reader, - ); + }); preparers.register('dir', directoryPreparer); return preparers; diff --git a/plugins/techdocs-node/src/stages/prepare/url.ts b/plugins/techdocs-node/src/stages/prepare/url.ts index 8026dca41e..0d2907d7d1 100644 --- a/plugins/techdocs-node/src/stages/prepare/url.ts +++ b/plugins/techdocs-node/src/stages/prepare/url.ts @@ -34,12 +34,6 @@ export class UrlPreparer implements PreparerBase { private readonly logger: Logger; private readonly reader: UrlReader; - /** @deprecated use static fromConfig method instead */ - constructor(reader: UrlReader, logger: Logger) { - this.logger = logger; - this.reader = reader; - } - /** * Returns a directory preparer instance * @param config - A URL preparer config containing the a logger and reader @@ -48,6 +42,11 @@ export class UrlPreparer implements PreparerBase { return new UrlPreparer(reader, logger); } + private constructor(reader: UrlReader, logger: Logger) { + this.logger = logger; + this.reader = reader; + } + /** {@inheritDoc PreparerBase.prepare} */ async prepare( entity: Entity, From b83063afe030b45a8bf363162a8bf0ffd61acf10 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 14 Mar 2022 14:11:48 +0100 Subject: [PATCH 3/9] clean up deprecations of techdocs-backend plugin Signed-off-by: Emma Indal --- plugins/techdocs-backend/config.d.ts | 24 -------------- .../techdocs-backend/src/service/router.ts | 33 +------------------ 2 files changed, 1 insertion(+), 56 deletions(-) diff --git a/plugins/techdocs-backend/config.d.ts b/plugins/techdocs-backend/config.d.ts index 8d531e0536..d4782ff406 100644 --- a/plugins/techdocs-backend/config.d.ts +++ b/plugins/techdocs-backend/config.d.ts @@ -46,17 +46,6 @@ export interface Config { pullImage?: boolean; }; - /** - * Techdocs generator information - * @deprecated Replaced with techdocs.generator - */ - generators?: { - /** - * @deprecated Use techdocs.generator.runIn - */ - techdocs: 'local' | 'docker'; - }; - /** * Techdocs publisher information */ @@ -252,19 +241,6 @@ export interface Config { readTimeout?: number; }; - /** - * @example http://localhost:7007/api/techdocs - * @visibility frontend - * @deprecated - */ - requestUrl?: string; - - /** - * @example http://localhost:7007/api/techdocs/static/docs - * @deprecated - */ - storageUrl?: string; - /** * (Optional and not recommended) Prior to version [0.x.y] of TechDocs, docs * sites could only be accessed over paths with case-sensitive entity triplets diff --git a/plugins/techdocs-backend/src/service/router.ts b/plugins/techdocs-backend/src/service/router.ts index e404c1b6d2..a56657cb9b 100644 --- a/plugins/techdocs-backend/src/service/router.ts +++ b/plugins/techdocs-backend/src/service/router.ts @@ -208,15 +208,7 @@ export async function createRouter( throw new NotFoundError('Entity metadata UID missing'); } - let responseHandler: DocsSynchronizerSyncOpts; - if (req.header('accept') !== 'text/event-stream') { - console.warn( - "The call to /sync/:namespace/:kind/:name wasn't done by an EventSource. This behavior is deprecated and will be removed soon. Make sure to update the @backstage/plugin-techdocs package in the frontend to the latest version.", - ); - responseHandler = createHttpResponse(res); - } else { - responseHandler = createEventStream(res); - } + const responseHandler: DocsSynchronizerSyncOpts = createEventStream(res); // By default, techdocs-backend will only try to build documentation for an entity if techdocs.builder is set to // 'local'. If set to 'external', it will assume that an external process (e.g. CI/CD pipeline @@ -345,26 +337,3 @@ export function createEventStream( }, }; } - -/** - * @deprecated use event-stream implementation of the sync endpoint - */ -export function createHttpResponse( - res: Response, -): DocsSynchronizerSyncOpts { - return { - log: () => {}, - error: e => { - throw e; - }, - finish: ({ updated }) => { - if (!updated) { - throw new NotModifiedError(); - } - - res - .status(201) - .json({ message: 'Docs updated or did not need updating' }); - }, - }; -} From b44692890b1c6ca1df55313612a1d28e3c61ea8a Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 14 Mar 2022 15:27:51 +0100 Subject: [PATCH 4/9] tests fixups Signed-off-by: Emma Indal --- .../techdocs-cli-embedded-app/app-config.yaml | 1 - .../techdocs-cli-embedded-app/src/apis.ts | 15 +- .../components/TechDocsPage/TechDocsPage.tsx | 12 +- .../techdocs-cli-embedded-app/src/config.ts | 2 - .../src/service/router.test.ts | 167 +----------------- .../src/service/standaloneServer.ts | 7 +- .../src/stages/publish/awsS3.test.ts | 1 - .../stages/publish/azureBlobStorage.test.ts | 1 - .../src/stages/publish/googleStorage.test.ts | 1 - .../src/stages/publish/openStackSwift.test.ts | 2 - .../src/stages/publish/publish.test.ts | 12 +- plugins/techdocs/src/client.test.ts | 4 +- .../reader/components/TechDocsReaderPage.tsx | 31 +++- 13 files changed, 44 insertions(+), 212 deletions(-) diff --git a/packages/techdocs-cli-embedded-app/app-config.yaml b/packages/techdocs-cli-embedded-app/app-config.yaml index 56e63ff97c..6ede05b587 100644 --- a/packages/techdocs-cli-embedded-app/app-config.yaml +++ b/packages/techdocs-cli-embedded-app/app-config.yaml @@ -7,4 +7,3 @@ backend: techdocs: builder: 'external' - requestUrl: http://localhost:3000/api diff --git a/packages/techdocs-cli-embedded-app/src/apis.ts b/packages/techdocs-cli-embedded-app/src/apis.ts index 1fe6ba8086..d230a9f83c 100644 --- a/packages/techdocs-cli-embedded-app/src/apis.ts +++ b/packages/techdocs-cli-embedded-app/src/apis.ts @@ -64,17 +64,11 @@ class TechDocsDevStorageApi implements TechDocsStorageApi { } async getApiOrigin() { - return ( - this.configApi.getOptionalString('techdocs.requestUrl') ?? - (await this.discoveryApi.getBaseUrl('techdocs')) - ); + return await this.discoveryApi.getBaseUrl('techdocs'); } async getStorageUrl() { - return ( - this.configApi.getOptionalString('techdocs.storageUrl') ?? - `${await this.discoveryApi.getBaseUrl('techdocs')}/static/docs` - ); + return `${await this.discoveryApi.getBaseUrl('techdocs')}/static/docs`; } async getBuilder() { @@ -134,10 +128,7 @@ class TechDocsDevApi implements TechDocsApi { } async getApiOrigin() { - return ( - this.configApi.getOptionalString('techdocs.requestUrl') ?? - (await this.discoveryApi.getBaseUrl('techdocs')) - ); + return await this.discoveryApi.getBaseUrl('techdocs'); } async getEntityMetadata(_entityId: any) { diff --git a/packages/techdocs-cli-embedded-app/src/components/TechDocsPage/TechDocsPage.tsx b/packages/techdocs-cli-embedded-app/src/components/TechDocsPage/TechDocsPage.tsx index f2dcefc00e..56686dd081 100644 --- a/packages/techdocs-cli-embedded-app/src/components/TechDocsPage/TechDocsPage.tsx +++ b/packages/techdocs-cli-embedded-app/src/components/TechDocsPage/TechDocsPage.tsx @@ -35,8 +35,8 @@ import { Content } from '@backstage/core-components'; import { Reader, - TechDocsPage, - TechDocsPageHeader, + TechDocsReaderPage, + TechDocsReaderPageHeader, } from '@backstage/plugin-techdocs'; const useStyles = makeStyles((theme: Theme) => ({ @@ -146,19 +146,19 @@ const DefaultTechDocsPage = () => { }; return ( - + {({ entityRef, onReady }) => ( <> - - + )} - + ); }; diff --git a/packages/techdocs-cli-embedded-app/src/config.ts b/packages/techdocs-cli-embedded-app/src/config.ts index 482ceb41ec..ae801dac2a 100644 --- a/packages/techdocs-cli-embedded-app/src/config.ts +++ b/packages/techdocs-cli-embedded-app/src/config.ts @@ -22,7 +22,6 @@ const PRODUCTION_CONFIG = { }, techdocs: { builder: 'external', - requestUrl: 'http://localhost:3000/api', }, }; @@ -32,7 +31,6 @@ const DEVELOPMENT_CONFIG = { }, techdocs: { builder: 'external', - requestUrl: 'http://localhost:7007/api', }, }; diff --git a/plugins/techdocs-backend/src/service/router.test.ts b/plugins/techdocs-backend/src/service/router.test.ts index 2e707c9513..f3f9892f44 100644 --- a/plugins/techdocs-backend/src/service/router.test.ts +++ b/plugins/techdocs-backend/src/service/router.test.ts @@ -21,7 +21,6 @@ import { PluginEndpointDiscovery, } from '@backstage/backend-common'; import { ConfigReader } from '@backstage/config'; -import { NotModifiedError } from '@backstage/errors'; import { GeneratorBuilder, PreparerBuilder, @@ -31,12 +30,7 @@ import express, { Response } from 'express'; import request from 'supertest'; import { DocsSynchronizer, DocsSynchronizerSyncOpts } from './DocsSynchronizer'; import { CachedEntityLoader } from './CachedEntityLoader'; -import { - createEventStream, - createHttpResponse, - createRouter, - RouterOptions, -} from './router'; +import { createEventStream, createRouter, RouterOptions } from './router'; import { TechDocsCache } from '../cache'; import { DocsBuildStrategy } from './DocsBuildStrategy'; @@ -160,120 +154,6 @@ describe('createRouter', () => { }); describe('GET /sync/:namespace/:kind/:name', () => { - describe('accept application/json', () => { - it('should return not found if entity is not found', async () => { - const app = await createApp(outOfTheBoxOptions); - - MockCachedEntityLoader.prototype.load.mockResolvedValue(undefined); - - const response = await request(app) - .get('/sync/default/Component/test') - .send(); - - expect(response.status).toBe(404); - }); - - it('should return not found if entity has no uid', async () => { - const app = await createApp(outOfTheBoxOptions); - - MockCachedEntityLoader.prototype.load.mockResolvedValue( - entityWithoutMetadata, - ); - - const response = await request(app) - .get('/sync/default/Component/test') - .send(); - - expect(response.status).toBe(404); - }); - - it('should not check for an update when shouldBuild returns false', async () => { - const app = await createApp(outOfTheBoxOptions); - - docsBuildStrategy.shouldBuild.mockResolvedValue(false); - MockCachedEntityLoader.prototype.load.mockResolvedValue(entity); - MockDocsSynchronizer.prototype.doCacheSync.mockImplementation( - async ({ responseHandler }) => - responseHandler.finish({ updated: false }), - ); - - const response = await request(app) - .get('/sync/default/Component/test') - .send(); - - expect(response.status).toBe(304); - }); - - it('should error if build is required and is missing preparer', async () => { - const app = await createApp(recommendedOptions); - - docsBuildStrategy.shouldBuild.mockResolvedValue(true); - MockCachedEntityLoader.prototype.load.mockResolvedValue(entity); - - const response = await request(app) - .get('/sync/default/Component/test') - .send(); - - expect(response.status).toBe(500); - expect(response.text).toMatch( - /Invalid configuration\. docsBuildStrategy\.shouldBuild returned 'true', but no 'preparer' was provided to the router initialization./, - ); - - expect(MockDocsSynchronizer.prototype.doSync).toBeCalledTimes(0); - }); - - it('should execute synchronization', async () => { - const app = await createApp(outOfTheBoxOptions); - - docsBuildStrategy.shouldBuild.mockResolvedValue(true); - MockCachedEntityLoader.prototype.load.mockResolvedValue(entity); - MockDocsSynchronizer.prototype.doSync.mockImplementation( - async ({ responseHandler }) => - responseHandler.finish({ updated: true }), - ); - - await request(app).get('/sync/default/Component/test').send(); - - expect(MockDocsSynchronizer.prototype.doSync).toBeCalledTimes(1); - expect(MockDocsSynchronizer.prototype.doSync).toBeCalledWith({ - responseHandler: { - log: expect.any(Function), - error: expect.any(Function), - finish: expect.any(Function), - }, - entity, - generators, - preparers, - }); - }); - - it('should return on updated', async () => { - const app = await createApp(outOfTheBoxOptions); - - docsBuildStrategy.shouldBuild.mockResolvedValue(true); - MockCachedEntityLoader.prototype.load.mockResolvedValue(entity); - MockDocsSynchronizer.prototype.doSync.mockImplementation( - async ({ responseHandler }) => { - const { log, finish } = responseHandler; - - log('Some log'); - - finish({ updated: true }); - }, - ); - - const response = await request(app) - .get('/sync/default/Component/test') - .send(); - - expect(response.status).toBe(201); - expect(response.get('content-type')).toMatch(/application\/json/); - expect(response.text).toEqual( - '{"message":"Docs updated or did not need updating"}', - ); - }); - }); - describe('accept text/event-stream', () => { it('should return not found if entity is not found', async () => { const app = await createApp(outOfTheBoxOptions); @@ -559,48 +439,3 @@ data: {"updated":true} expect(res.end).toBeCalledTimes(1); }); }); - -describe('createHttpResponse', () => { - const res: jest.Mocked = { - status: jest.fn(), - json: jest.fn(), - } as any; - - let handlers: DocsSynchronizerSyncOpts; - - beforeEach(() => { - res.status.mockImplementation(() => res); - handlers = createHttpResponse(res); - }); - afterEach(() => { - jest.resetAllMocks(); - }); - - it('should return CREATED if updated', async () => { - handlers.finish({ updated: true }); - - expect(res.status).toBeCalledTimes(1); - expect(res.status).toBeCalledWith(201); - - expect(res.json).toBeCalledTimes(1); - expect(res.json).toBeCalledWith({ - message: 'Docs updated or did not need updating', - }); - }); - - it('should return NOT_MODIFIED if not updated', async () => { - expect(() => handlers.finish({ updated: false })).toThrowError( - NotModifiedError, - ); - }); - - it('should throw custom error', async () => { - expect(() => handlers.error(new Error('Some Error'))).toThrowError( - /Some Error/, - ); - }); - - it('should ignore logs', async () => { - expect(() => handlers.log('Some Message')).not.toThrow(); - }); -}); diff --git a/plugins/techdocs-backend/src/service/standaloneServer.ts b/plugins/techdocs-backend/src/service/standaloneServer.ts index 4ab4c084e0..f0ee42ba4a 100644 --- a/plugins/techdocs-backend/src/service/standaloneServer.ts +++ b/plugins/techdocs-backend/src/service/standaloneServer.ts @@ -60,11 +60,10 @@ export async function startStandaloneServer( logger.debug('Creating application...'); const preparers = new Preparers(); - const directoryPreparer = new DirectoryPreparer( - config, + const directoryPreparer = DirectoryPreparer.fromConfig(config, { logger, - mockUrlReader, - ); + reader: mockUrlReader, + }); preparers.register('dir', directoryPreparer); const dockerClient = new Docker(); diff --git a/plugins/techdocs-node/src/stages/publish/awsS3.test.ts b/plugins/techdocs-node/src/stages/publish/awsS3.test.ts index 326e587a83..537fc52b27 100644 --- a/plugins/techdocs-node/src/stages/publish/awsS3.test.ts +++ b/plugins/techdocs-node/src/stages/publish/awsS3.test.ts @@ -54,7 +54,6 @@ const createPublisherFromConfig = ({ } = {}) => { const mockConfig = new ConfigReader({ techdocs: { - requestUrl: 'http://localhost:7007', publisher: { type: 'awsS3', awsS3: { diff --git a/plugins/techdocs-node/src/stages/publish/azureBlobStorage.test.ts b/plugins/techdocs-node/src/stages/publish/azureBlobStorage.test.ts index 3e5e420e4b..7af5338d88 100644 --- a/plugins/techdocs-node/src/stages/publish/azureBlobStorage.test.ts +++ b/plugins/techdocs-node/src/stages/publish/azureBlobStorage.test.ts @@ -51,7 +51,6 @@ const createPublisherFromConfig = ({ } = {}) => { const config = new ConfigReader({ techdocs: { - requestUrl: 'http://localhost:7007', publisher: { type: 'azureBlobStorage', azureBlobStorage: { diff --git a/plugins/techdocs-node/src/stages/publish/googleStorage.test.ts b/plugins/techdocs-node/src/stages/publish/googleStorage.test.ts index 6dac092cec..6471d89a06 100644 --- a/plugins/techdocs-node/src/stages/publish/googleStorage.test.ts +++ b/plugins/techdocs-node/src/stages/publish/googleStorage.test.ts @@ -52,7 +52,6 @@ const createPublisherFromConfig = ({ } = {}) => { const config = new ConfigReader({ techdocs: { - requestUrl: 'http://localhost:7007', publisher: { type: 'googleGcs', googleGcs: { diff --git a/plugins/techdocs-node/src/stages/publish/openStackSwift.test.ts b/plugins/techdocs-node/src/stages/publish/openStackSwift.test.ts index aeb4e120f5..619431fdd7 100644 --- a/plugins/techdocs-node/src/stages/publish/openStackSwift.test.ts +++ b/plugins/techdocs-node/src/stages/publish/openStackSwift.test.ts @@ -84,7 +84,6 @@ beforeEach(() => { mockFs.restore(); const mockConfig = new ConfigReader({ techdocs: { - requestUrl: 'http://localhost:7007', publisher: { type: 'openStackSwift', openStackSwift: { @@ -114,7 +113,6 @@ describe('OpenStackSwiftPublish', () => { it('should reject incorrect config', async () => { const mockConfig = new ConfigReader({ techdocs: { - requestUrl: 'http://localhost:7007', publisher: { type: 'openStackSwift', openStackSwift: { diff --git a/plugins/techdocs-node/src/stages/publish/publish.test.ts b/plugins/techdocs-node/src/stages/publish/publish.test.ts index a47da828a7..4537313edf 100644 --- a/plugins/techdocs-node/src/stages/publish/publish.test.ts +++ b/plugins/techdocs-node/src/stages/publish/publish.test.ts @@ -37,11 +37,7 @@ describe('Publisher', () => { }); it('should create local publisher by default', async () => { - const mockConfig = new ConfigReader({ - techdocs: { - requestUrl: 'http://localhost:7007', - }, - }); + const mockConfig = new ConfigReader({}); const publisher = await Publisher.fromConfig(mockConfig, { logger, @@ -53,7 +49,6 @@ describe('Publisher', () => { it('should create local publisher from config', async () => { const mockConfig = new ConfigReader({ techdocs: { - requestUrl: 'http://localhost:7007', publisher: { type: 'local', }, @@ -70,7 +65,6 @@ describe('Publisher', () => { it('should create google gcs publisher from config', async () => { const mockConfig = new ConfigReader({ techdocs: { - requestUrl: 'http://localhost:7007', publisher: { type: 'googleGcs', googleGcs: { @@ -91,7 +85,6 @@ describe('Publisher', () => { it('should create AWS S3 publisher from config', async () => { const mockConfig = new ConfigReader({ techdocs: { - requestUrl: 'http://localhost:7007', publisher: { type: 'awsS3', awsS3: { @@ -115,7 +108,6 @@ describe('Publisher', () => { it('should create Azure Blob Storage publisher from config', async () => { const mockConfig = new ConfigReader({ techdocs: { - requestUrl: 'http://localhost:7007', publisher: { type: 'azureBlobStorage', azureBlobStorage: { @@ -143,7 +135,6 @@ describe('Publisher', () => { const mockConfig = new ConfigReader({ techdocs: { - requestUrl: 'http://localhost:7007', publisher: { type: 'azureBlobStorage', azureBlobStorage: { @@ -166,7 +157,6 @@ describe('Publisher', () => { it('should create Open Stack Swift publisher from config', async () => { const mockConfig = new ConfigReader({ techdocs: { - requestUrl: 'http://localhost:7007', publisher: { type: 'openStackSwift', openStackSwift: { diff --git a/plugins/techdocs/src/client.test.ts b/plugins/techdocs/src/client.test.ts index a88c724cc8..71ad57d12a 100644 --- a/plugins/techdocs/src/client.test.ts +++ b/plugins/techdocs/src/client.test.ts @@ -35,9 +35,7 @@ const mockEntity = { describe('TechDocsStorageClient', () => { const mockBaseUrl = 'http://backstage:9191/api/techdocs'; - const configApi = new MockConfigApi({ - techdocs: { requestUrl: 'http://backstage:9191/api/techdocs' }, - }); + const configApi = new MockConfigApi({}); const discoveryApi = UrlPatternDiscovery.compile(mockBaseUrl); const identityApi: jest.Mocked = { getCredentials: jest.fn(), diff --git a/plugins/techdocs/src/reader/components/TechDocsReaderPage.tsx b/plugins/techdocs/src/reader/components/TechDocsReaderPage.tsx index ff44d429df..1bfd0e6f51 100644 --- a/plugins/techdocs/src/reader/components/TechDocsReaderPage.tsx +++ b/plugins/techdocs/src/reader/components/TechDocsReaderPage.tsx @@ -18,11 +18,13 @@ import React, { useCallback, useState } from 'react'; import { useOutlet } from 'react-router'; import { useParams } from 'react-router-dom'; import useAsync from 'react-use/lib/useAsync'; +import { Reader } from './Reader'; +import { TechDocsReaderPageHeader } from './TechDocsReaderPageHeader'; import { techdocsApiRef } from '../../api'; import { TechDocsEntityMetadata, TechDocsMetadata } from '../../types'; import { CompoundEntityRef } from '@backstage/catalog-model'; import { useApi, useApp } from '@backstage/core-plugin-api'; -import { Page } from '@backstage/core-components'; +import { Page, Content } from '@backstage/core-components'; /** * Helper function that gives the children of {@link TechDocsReaderPage} access to techdocs and entity metadata @@ -78,7 +80,32 @@ export const TechDocsReaderPage = (props: TechDocsReaderPageProps) => { if (entityMetadataError) return ; - if (!children) return outlet; + if (!children) + return ( + outlet || ( + + + + + + + ) + ); return ( From 1bc516bdfbb9a00975f363411a29cdff28bcf2ab Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 14 Mar 2022 15:35:57 +0100 Subject: [PATCH 5/9] remove unused import Signed-off-by: Emma Indal --- plugins/techdocs-backend/src/service/router.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/techdocs-backend/src/service/router.ts b/plugins/techdocs-backend/src/service/router.ts index a56657cb9b..148143e460 100644 --- a/plugins/techdocs-backend/src/service/router.ts +++ b/plugins/techdocs-backend/src/service/router.ts @@ -20,7 +20,7 @@ import { import { CatalogClient } from '@backstage/catalog-client'; import { stringifyEntityRef } from '@backstage/catalog-model'; import { Config } from '@backstage/config'; -import { NotFoundError, NotModifiedError } from '@backstage/errors'; +import { NotFoundError } from '@backstage/errors'; import { GeneratorBuilder, getLocationForEntity, From da7d91fcdc5bfb440eadf51ee1f8f77bf5921e2c Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 14 Mar 2022 21:54:55 +0100 Subject: [PATCH 6/9] api report fixup Signed-off-by: Emma Indal --- plugins/techdocs-backend/api-report.md | 10 +++++----- plugins/techdocs/api-report.md | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/techdocs-backend/api-report.md b/plugins/techdocs-backend/api-report.md index 157f049953..f306ce4f35 100644 --- a/plugins/techdocs-backend/api-report.md +++ b/plugins/techdocs-backend/api-report.md @@ -12,7 +12,7 @@ import { Entity } from '@backstage/catalog-model'; import express from 'express'; import { GeneratorBuilder } from '@backstage/plugin-techdocs-node'; import { Knex } from 'knex'; -import { Logger } from 'winston'; +import { Logger as Logger_2 } from 'winston'; import { Permission } from '@backstage/plugin-permission-common'; import { PluginCacheManager } from '@backstage/backend-common'; import { PluginEndpointDiscovery } from '@backstage/backend-common'; @@ -71,7 +71,7 @@ export type OutOfTheBoxDeploymentOptions = { preparers: PreparerBuilder; generators: GeneratorBuilder; publisher: PublisherBase; - logger: Logger; + logger: Logger_2; discovery: PluginEndpointDiscovery; database?: Knex; config: Config; @@ -82,7 +82,7 @@ export type OutOfTheBoxDeploymentOptions = { // @public export type RecommendedDeploymentOptions = { publisher: PublisherBase; - logger: Logger; + logger: Logger_2; discovery: PluginEndpointDiscovery; config: Config; cache: PluginCacheManager; @@ -102,7 +102,7 @@ export type ShouldBuildParameters = { // @public export type TechDocsCollatorFactoryOptions = { discovery: PluginEndpointDiscovery; - logger: Logger; + logger: Logger_2; tokenManager: TokenManager; locationTemplate?: string; catalogClient?: CatalogApi; @@ -113,7 +113,7 @@ export type TechDocsCollatorFactoryOptions = { // @public export type TechDocsCollatorOptions = { discovery: PluginEndpointDiscovery; - logger: Logger; + logger: Logger_2; tokenManager: TokenManager; locationTemplate?: string; catalogClient?: CatalogApi; diff --git a/plugins/techdocs/api-report.md b/plugins/techdocs/api-report.md index e6f9d463ed..ecab23e225 100644 --- a/plugins/techdocs/api-report.md +++ b/plugins/techdocs/api-report.md @@ -274,7 +274,7 @@ export { techdocsPlugin }; // @public export const TechDocsReaderPage: ( props: TechDocsReaderPageProps, -) => JSX.Element | null; +) => JSX.Element; // @public export const TechDocsReaderPageHeader: ( From 700d93ff41e1ba2fe25bf49ac9ffba97f2acc7a1 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Mon, 14 Mar 2022 23:15:48 +0100 Subject: [PATCH 7/9] add changesets Signed-off-by: Emma Indal --- .changeset/techdocs-breezy-pans-flow.md | 8 ++++++++ .changeset/techdocs-clever-pumas-warn.md | 11 +++++++++++ .changeset/techdocs-tiny-spies-knock.md | 13 +++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 .changeset/techdocs-breezy-pans-flow.md create mode 100644 .changeset/techdocs-clever-pumas-warn.md create mode 100644 .changeset/techdocs-tiny-spies-knock.md diff --git a/.changeset/techdocs-breezy-pans-flow.md b/.changeset/techdocs-breezy-pans-flow.md new file mode 100644 index 0000000000..a3c0776bf2 --- /dev/null +++ b/.changeset/techdocs-breezy-pans-flow.md @@ -0,0 +1,8 @@ +--- +'@backstage/plugin-techdocs-node': patch +--- + +Deprecations cleaned up. + +- `DirectoryPreparer` now uses private constructor. Use static fromConfig method to instantiate. +- `UrlPreparer` now uses private constructor. Use static fromConfig method to instantiate. diff --git a/.changeset/techdocs-clever-pumas-warn.md b/.changeset/techdocs-clever-pumas-warn.md new file mode 100644 index 0000000000..3804df599a --- /dev/null +++ b/.changeset/techdocs-clever-pumas-warn.md @@ -0,0 +1,11 @@ +--- +'@backstage/plugin-techdocs-backend': patch +--- + +Deprecations cleaned up. + +- deprecated config `generators` is now deleted and fully replaced with `techdocs.generator` +- deprecated config `generators.techdocs` is now deleted and fully replaced with `techdocs.generator.runIn` +- deprecated config `techdocs.requestUrl` is now deleted +- deprecated config `techdocs.storageUrl` is now deleted +- deprecated `createHttpResponse` is now deleted and calls to `/sync/:namespace/:kind/:name` needs to be done by an EventSource. diff --git a/.changeset/techdocs-tiny-spies-knock.md b/.changeset/techdocs-tiny-spies-knock.md new file mode 100644 index 0000000000..39acf6df10 --- /dev/null +++ b/.changeset/techdocs-tiny-spies-knock.md @@ -0,0 +1,13 @@ +--- +'@backstage/plugin-techdocs': patch +--- + +Deprecations cleaned up. + +- deprecated `DocsResultListItem` is now deleted and fully replaced with `TechDocsSearchResultListItem` +- deprecated `TechDocsPage` is now deleted and fully replaced with `TechDocsReaderPage` +- deprecated `TechDocsPageHeader` is now deleted and fully replaced with `TechDocsReaderPageHeader` + +- deprecated `TechDocsPageHeaderProps` is now deleted and fully replaced with `TechDocsReaderPageHeaderProps` +- deprecated `TechDocsPageRenderFunction` is now deleted and fully replaced with `TechDocsReaderPageRenderFunction` +- deprecated config `techdocs.requestUrl` is now deleted and fully replaced with the discoveryApi From 9234be033cbcd8d132045b3a72acef5f537eacb0 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Tue, 15 Mar 2022 09:35:57 +0100 Subject: [PATCH 8/9] api reports logger fixup Signed-off-by: Emma Indal --- plugins/techdocs-backend/api-report.md | 10 +++++----- plugins/techdocs-node/api-report.md | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/techdocs-backend/api-report.md b/plugins/techdocs-backend/api-report.md index f306ce4f35..157f049953 100644 --- a/plugins/techdocs-backend/api-report.md +++ b/plugins/techdocs-backend/api-report.md @@ -12,7 +12,7 @@ import { Entity } from '@backstage/catalog-model'; import express from 'express'; import { GeneratorBuilder } from '@backstage/plugin-techdocs-node'; import { Knex } from 'knex'; -import { Logger as Logger_2 } from 'winston'; +import { Logger } from 'winston'; import { Permission } from '@backstage/plugin-permission-common'; import { PluginCacheManager } from '@backstage/backend-common'; import { PluginEndpointDiscovery } from '@backstage/backend-common'; @@ -71,7 +71,7 @@ export type OutOfTheBoxDeploymentOptions = { preparers: PreparerBuilder; generators: GeneratorBuilder; publisher: PublisherBase; - logger: Logger_2; + logger: Logger; discovery: PluginEndpointDiscovery; database?: Knex; config: Config; @@ -82,7 +82,7 @@ export type OutOfTheBoxDeploymentOptions = { // @public export type RecommendedDeploymentOptions = { publisher: PublisherBase; - logger: Logger_2; + logger: Logger; discovery: PluginEndpointDiscovery; config: Config; cache: PluginCacheManager; @@ -102,7 +102,7 @@ export type ShouldBuildParameters = { // @public export type TechDocsCollatorFactoryOptions = { discovery: PluginEndpointDiscovery; - logger: Logger_2; + logger: Logger; tokenManager: TokenManager; locationTemplate?: string; catalogClient?: CatalogApi; @@ -113,7 +113,7 @@ export type TechDocsCollatorFactoryOptions = { // @public export type TechDocsCollatorOptions = { discovery: PluginEndpointDiscovery; - logger: Logger_2; + logger: Logger; tokenManager: TokenManager; locationTemplate?: string; catalogClient?: CatalogApi; diff --git a/plugins/techdocs-node/api-report.md b/plugins/techdocs-node/api-report.md index a5446c77cd..350e67e1c3 100644 --- a/plugins/techdocs-node/api-report.md +++ b/plugins/techdocs-node/api-report.md @@ -11,7 +11,7 @@ import { ContainerRunner } from '@backstage/backend-common'; import { Entity } from '@backstage/catalog-model'; import express from 'express'; import { IndexableDocument } from '@backstage/plugin-search-common'; -import { Logger as Logger_2 } from 'winston'; +import { Logger } from 'winston'; import { PluginEndpointDiscovery } from '@backstage/backend-common'; import { ScmIntegrationRegistry } from '@backstage/integration'; import { UrlReader } from '@backstage/backend-common'; @@ -43,7 +43,7 @@ export type GeneratorBuilder = { // @public export type GeneratorOptions = { containerRunner: ContainerRunner; - logger: Logger_2; + logger: Logger; }; // @public @@ -52,7 +52,7 @@ export type GeneratorRunOptions = { outputDir: string; parsedLocationAnnotation?: ParsedLocationAnnotation; etag?: string; - logger: Logger_2; + logger: Logger; logStream?: Writable; }; @@ -61,7 +61,7 @@ export class Generators implements GeneratorBuilder { static fromConfig( config: Config, options: { - logger: Logger_2; + logger: Logger; containerRunner: ContainerRunner; }, ): Promise; @@ -76,7 +76,7 @@ export const getDocFilesFromRepository: ( opts?: | { etag?: string | undefined; - logger?: Logger_2 | undefined; + logger?: Logger | undefined; } | undefined, ) => Promise; @@ -118,13 +118,13 @@ export type PreparerBuilder = { // @public export type PreparerConfig = { - logger: Logger_2; + logger: Logger; reader: UrlReader; }; // @public export type PreparerOptions = { - logger?: Logger_2; + logger?: Logger; etag?: ETag; }; @@ -166,7 +166,7 @@ export interface PublisherBase { // @public export type PublisherFactory = { - logger: Logger_2; + logger: Logger; discovery: PluginEndpointDiscovery; }; @@ -214,7 +214,7 @@ export interface TechDocsDocument extends IndexableDocument { // @public export class TechdocsGenerator implements GeneratorBase { constructor(options: { - logger: Logger_2; + logger: Logger; containerRunner: ContainerRunner; config: Config; scmIntegrations: ScmIntegrationRegistry; From 0d917bf6f7a8bd4ea8b38894d7460d8cdcdf5f14 Mon Sep 17 00:00:00 2001 From: Emma Indal Date: Tue, 15 Mar 2022 09:39:12 +0100 Subject: [PATCH 9/9] changes to be minor Signed-off-by: Emma Indal --- .changeset/techdocs-breezy-pans-flow.md | 4 +--- .changeset/techdocs-clever-pumas-warn.md | 4 ++-- .changeset/techdocs-tiny-spies-knock.md | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.changeset/techdocs-breezy-pans-flow.md b/.changeset/techdocs-breezy-pans-flow.md index a3c0776bf2..933a383c38 100644 --- a/.changeset/techdocs-breezy-pans-flow.md +++ b/.changeset/techdocs-breezy-pans-flow.md @@ -1,8 +1,6 @@ --- -'@backstage/plugin-techdocs-node': patch +'@backstage/plugin-techdocs-node': minor --- -Deprecations cleaned up. - - `DirectoryPreparer` now uses private constructor. Use static fromConfig method to instantiate. - `UrlPreparer` now uses private constructor. Use static fromConfig method to instantiate. diff --git a/.changeset/techdocs-clever-pumas-warn.md b/.changeset/techdocs-clever-pumas-warn.md index 3804df599a..2aba8b9885 100644 --- a/.changeset/techdocs-clever-pumas-warn.md +++ b/.changeset/techdocs-clever-pumas-warn.md @@ -1,8 +1,8 @@ --- -'@backstage/plugin-techdocs-backend': patch +'@backstage/plugin-techdocs-backend': minor --- -Deprecations cleaned up. +Removed deprecated exports, including: - deprecated config `generators` is now deleted and fully replaced with `techdocs.generator` - deprecated config `generators.techdocs` is now deleted and fully replaced with `techdocs.generator.runIn` diff --git a/.changeset/techdocs-tiny-spies-knock.md b/.changeset/techdocs-tiny-spies-knock.md index 39acf6df10..ffc3e75a01 100644 --- a/.changeset/techdocs-tiny-spies-knock.md +++ b/.changeset/techdocs-tiny-spies-knock.md @@ -1,13 +1,12 @@ --- -'@backstage/plugin-techdocs': patch +'@backstage/plugin-techdocs': minor --- -Deprecations cleaned up. +Removed deprecated exports, including: - deprecated `DocsResultListItem` is now deleted and fully replaced with `TechDocsSearchResultListItem` - deprecated `TechDocsPage` is now deleted and fully replaced with `TechDocsReaderPage` - deprecated `TechDocsPageHeader` is now deleted and fully replaced with `TechDocsReaderPageHeader` - - deprecated `TechDocsPageHeaderProps` is now deleted and fully replaced with `TechDocsReaderPageHeaderProps` - deprecated `TechDocsPageRenderFunction` is now deleted and fully replaced with `TechDocsReaderPageRenderFunction` - deprecated config `techdocs.requestUrl` is now deleted and fully replaced with the discoveryApi