From 76a21aad7e7d3aca2975585f267241e028768ec7 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 10:47:31 +0100 Subject: [PATCH] test-utils: migrate to use exports Signed-off-by: Patrik Oldsberg --- packages/test-utils/alpha-api-report.md | 14 +++++++++++ packages/test-utils/api-report.md | 6 ----- packages/test-utils/package.json | 24 +++++++++++++------ packages/test-utils/src/alpha.ts | 17 +++++++++++++ .../{providers.tsx => MockPluginProvider.tsx} | 0 packages/test-utils/src/testUtils/index.tsx | 1 - 6 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 packages/test-utils/alpha-api-report.md create mode 100644 packages/test-utils/src/alpha.ts rename packages/test-utils/src/testUtils/{providers.tsx => MockPluginProvider.tsx} (100%) diff --git a/packages/test-utils/alpha-api-report.md b/packages/test-utils/alpha-api-report.md new file mode 100644 index 0000000000..3e0c4aa6c2 --- /dev/null +++ b/packages/test-utils/alpha-api-report.md @@ -0,0 +1,14 @@ +## API Report File for "@backstage/test-utils" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { PropsWithChildren } from 'react'; + +// @alpha +export const MockPluginProvider: ({ + children, +}: PropsWithChildren<{}>) => JSX.Element; + +// (No @packageDocumentation comment for this package) +``` diff --git a/packages/test-utils/api-report.md b/packages/test-utils/api-report.md index e11072f5a6..37650ff18a 100644 --- a/packages/test-utils/api-report.md +++ b/packages/test-utils/api-report.md @@ -26,7 +26,6 @@ import { JsonValue } from '@backstage/types'; import { MatcherFunction } from '@testing-library/react'; import { Observable } from '@backstage/types'; import { PermissionApi } from '@backstage/plugin-permission-react'; -import { PropsWithChildren } from 'react'; import { ReactElement } from 'react'; import { ReactNode } from 'react'; import { RenderOptions } from '@testing-library/react'; @@ -167,11 +166,6 @@ export class MockPermissionApi implements PermissionApi { ): Promise; } -// @alpha -export const MockPluginProvider: ({ - children, -}: PropsWithChildren<{}>) => JSX.Element; - // @public export class MockStorageApi implements StorageApi { // (undocumented) diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json index 9e82ccc1d7..4148f62a3f 100644 --- a/packages/test-utils/package.json +++ b/packages/test-utils/package.json @@ -3,10 +3,21 @@ "description": "Utilities to test Backstage plugins and apps.", "version": "1.2.5", "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "web-library" @@ -24,7 +35,7 @@ "main": "src/index.ts", "types": "src/index.ts", "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -60,7 +71,6 @@ "msw": "^0.49.0" }, "files": [ - "dist", - "alpha" + "dist" ] } diff --git a/packages/test-utils/src/alpha.ts b/packages/test-utils/src/alpha.ts new file mode 100644 index 0000000000..0b2a6a8d1c --- /dev/null +++ b/packages/test-utils/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * 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. + */ + +export * from './testUtils/MockPluginProvider'; diff --git a/packages/test-utils/src/testUtils/providers.tsx b/packages/test-utils/src/testUtils/MockPluginProvider.tsx similarity index 100% rename from packages/test-utils/src/testUtils/providers.tsx rename to packages/test-utils/src/testUtils/MockPluginProvider.tsx diff --git a/packages/test-utils/src/testUtils/index.tsx b/packages/test-utils/src/testUtils/index.tsx index 8fc1395eb8..1510af106e 100644 --- a/packages/test-utils/src/testUtils/index.tsx +++ b/packages/test-utils/src/testUtils/index.tsx @@ -25,7 +25,6 @@ export { export type { TestAppOptions } from './appWrappers'; export * from './msw'; export * from './logCollector'; -export * from './providers'; export * from './testingLibrary'; export { TestApiProvider, TestApiRegistry } from './TestApiProvider'; export type { TestApiProviderProps } from './TestApiProvider';