diff --git a/.changeset/beige-carpets-double.md b/.changeset/beige-carpets-double.md new file mode 100644 index 0000000000..98e0d8d69a --- /dev/null +++ b/.changeset/beige-carpets-double.md @@ -0,0 +1,9 @@ +--- +'@backstage/plugin-code-coverage': minor +--- + +Cleaned up API exports. + +The `Router` export has been removed; users are expected to use `EntityCodeCoverageContent` instead. + +The `isPluginApplicableToEntity` helper has been deprecated, in favor of the `isCodeCoverageAvailable` helper. diff --git a/.changeset/beige-carpets-triple.md b/.changeset/beige-carpets-triple.md new file mode 100644 index 0000000000..5eda26fb02 --- /dev/null +++ b/.changeset/beige-carpets-triple.md @@ -0,0 +1,7 @@ +--- +'@backstage/plugin-code-coverage-backend': minor +--- + +Cleaned up API exports. + +The `CodeCoverageApi` and `makeRouter` exports have been removed from the backend, since they were not meant to be exported in the first place. diff --git a/plugins/code-coverage-backend/api-report.md b/plugins/code-coverage-backend/api-report.md index 437c48227f..c33874064b 100644 --- a/plugins/code-coverage-backend/api-report.md +++ b/plugins/code-coverage-backend/api-report.md @@ -10,27 +10,10 @@ import { PluginDatabaseManager } from '@backstage/backend-common'; import { PluginEndpointDiscovery } from '@backstage/backend-common'; import { UrlReader } from '@backstage/backend-common'; -// Warning: (ae-missing-release-tag) "CodeCoverageApi" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface CodeCoverageApi { - // (undocumented) - name: string; -} - -// Warning: (ae-missing-release-tag) "createRouter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) +// @public export function createRouter(options: RouterOptions): Promise; -// Warning: (ae-missing-release-tag) "makeRouter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export const makeRouter: (options: RouterOptions) => Promise; - -// Warning: (ae-missing-release-tag) "RouterOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) +// @public export interface RouterOptions { // (undocumented) config: Config; diff --git a/plugins/code-coverage-backend/src/index.ts b/plugins/code-coverage-backend/src/index.ts index 3b1b536ac7..8511c9b71e 100644 --- a/plugins/code-coverage-backend/src/index.ts +++ b/plugins/code-coverage-backend/src/index.ts @@ -20,4 +20,5 @@ * @packageDocumentation */ -export * from './service/router'; +export { createRouter } from './service/router'; +export type { RouterOptions } from './service/router'; diff --git a/plugins/code-coverage-backend/src/service/router.ts b/plugins/code-coverage-backend/src/service/router.ts index 488103c835..37279b549f 100644 --- a/plugins/code-coverage-backend/src/service/router.ts +++ b/plugins/code-coverage-backend/src/service/router.ts @@ -35,6 +35,11 @@ import { Jacoco } from './converter/jacoco'; import { Converter } from './converter'; import { getEntitySourceLocation } from '@backstage/catalog-model'; +/** + * Options for {@link createRouter}. + * + * @public + */ export interface RouterOptions { config: Config; discovery: PluginEndpointDiscovery; @@ -211,6 +216,11 @@ export const makeRouter = async ( return router; }; +/** + * Creates a code-coverage plugin backend router. + * + * @public + */ export async function createRouter( options: RouterOptions, ): Promise { diff --git a/plugins/code-coverage/api-report.md b/plugins/code-coverage/api-report.md index 0e675dec04..152cc93103 100644 --- a/plugins/code-coverage/api-report.md +++ b/plugins/code-coverage/api-report.md @@ -9,8 +9,6 @@ import { BackstagePlugin } from '@backstage/core-plugin-api'; import { Entity } from '@backstage/catalog-model'; import { RouteRef } from '@backstage/core-plugin-api'; -// Warning: (ae-missing-release-tag) "codeCoveragePlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export const codeCoveragePlugin: BackstagePlugin< { @@ -19,20 +17,12 @@ export const codeCoveragePlugin: BackstagePlugin< {} >; -// Warning: (ae-missing-release-tag) "EntityCodeCoverageContent" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) +// @public export const EntityCodeCoverageContent: () => JSX.Element; -// Warning: (ae-missing-release-tag) "isCodeCoverageAvailable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -const isCodeCoverageAvailable: (entity: Entity) => boolean; -export { isCodeCoverageAvailable }; -export { isCodeCoverageAvailable as isPluginApplicableToEntity }; +// @public +export function isCodeCoverageAvailable(entity: Entity): boolean; -// Warning: (ae-missing-release-tag) "Router" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export const Router: () => JSX.Element; +// @public @deprecated (undocumented) +export const isPluginApplicableToEntity: typeof isCodeCoverageAvailable; ``` diff --git a/plugins/code-coverage/src/components/FileExplorer/Highlighter.ts b/plugins/code-coverage/src/components/FileExplorer/Highlighter.ts index 225ca96175..d97d147da3 100644 --- a/plugins/code-coverage/src/components/FileExplorer/Highlighter.ts +++ b/plugins/code-coverage/src/components/FileExplorer/Highlighter.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import 'highlight.js/styles/atom-one-dark.css'; import highlight from 'highlight.js'; diff --git a/plugins/code-coverage/src/components/Router.tsx b/plugins/code-coverage/src/components/Router.tsx index d3342b86eb..190b441c7a 100644 --- a/plugins/code-coverage/src/components/Router.tsx +++ b/plugins/code-coverage/src/components/Router.tsx @@ -13,16 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import React from 'react'; import { Entity } from '@backstage/catalog-model'; import { useEntity } from '@backstage/plugin-catalog-react'; import { CodeCoveragePage } from './CodeCoveragePage'; import { MissingAnnotationEmptyState } from '@backstage/core-components'; -export const isCodeCoverageAvailable = (entity: Entity) => - Boolean(entity.metadata.annotations?.['backstage.io/code-coverage']); +/** + * Returns true if the given entity has code coverage enabled. + * + * @public + */ +export function isCodeCoverageAvailable(entity: Entity) { + return Boolean(entity.metadata.annotations?.['backstage.io/code-coverage']); +} -export const Router = () => { +/** + * @public + */ +export const Router = (): JSX.Element => { const { entity } = useEntity(); if (!isCodeCoverageAvailable(entity)) { @@ -30,5 +40,6 @@ export const Router = () => { ); } + return ; }; diff --git a/plugins/code-coverage/src/index.ts b/plugins/code-coverage/src/index.ts index 2ece7ed1e8..06c10026ff 100644 --- a/plugins/code-coverage/src/index.ts +++ b/plugins/code-coverage/src/index.ts @@ -20,9 +20,13 @@ * @packageDocumentation */ +import { isCodeCoverageAvailable } from './components/Router'; + export { codeCoveragePlugin, EntityCodeCoverageContent } from './plugin'; -export { - Router, - isCodeCoverageAvailable, - isCodeCoverageAvailable as isPluginApplicableToEntity, -} from './components/Router'; +export { isCodeCoverageAvailable }; + +/** + * @public + * @deprecated Use `isPluginApplicableToEntity` instead. + */ +export const isPluginApplicableToEntity = isCodeCoverageAvailable; diff --git a/plugins/code-coverage/src/plugin.ts b/plugins/code-coverage/src/plugin.ts index 1202c4e4b3..f137e9d488 100644 --- a/plugins/code-coverage/src/plugin.ts +++ b/plugins/code-coverage/src/plugin.ts @@ -23,6 +23,9 @@ import { discoveryApiRef, } from '@backstage/core-plugin-api'; +/** + * @public + */ export const codeCoveragePlugin = createPlugin({ id: 'code-coverage', routes: { @@ -37,6 +40,11 @@ export const codeCoveragePlugin = createPlugin({ ], }); +/** + * An entity code coverage page. + * + * @public + */ export const EntityCodeCoverageContent = codeCoveragePlugin.provide( createRoutableExtension({ name: 'EntityCodeCoverageContent', diff --git a/scripts/api-extractor.ts b/scripts/api-extractor.ts index 0d40ebb60a..21a307b65a 100644 --- a/scripts/api-extractor.ts +++ b/scripts/api-extractor.ts @@ -219,8 +219,6 @@ const ALLOW_WARNINGS = [ 'plugins/circleci', 'plugins/cloudbuild', 'plugins/code-climate', - 'plugins/code-coverage', - 'plugins/code-coverage-backend', 'plugins/config-schema', 'plugins/cost-insights', 'plugins/dynatrace',