plugins should not depend on core-api

This commit is contained in:
Fredrik Adelöw
2021-01-14 08:03:51 +01:00
parent a87014886a
commit a6f9dca0dc
13 changed files with 32 additions and 24 deletions
+7
View File
@@ -0,0 +1,7 @@
---
'@backstage/plugin-github-actions': patch
'@backstage/plugin-lighthouse': patch
'@backstage/plugin-techdocs': patch
---
Remove dependency on `@backstage/core-api`. No plugin should ever depend on that package; it's an internal concern whose important bits are re-exported by `@backstage/core` which is the public facing dependency to use.
@@ -14,8 +14,8 @@ import {
HeaderLabel,
SupportButton,
identityApiRef,
useApi,
} from '@backstage/core';
import { useApi } from '@backstage/core-api';
import ExampleFetchComponent from '../ExampleFetchComponent';
const ExampleComponent = () => {
@@ -11,8 +11,8 @@ import {
TableColumn,
Progress,
githubAuthApiRef,
useApi,
} from '@backstage/core';
import { useApi } from '@backstage/core-api';
import { graphql } from '@octokit/graphql';
const query = `{
+2 -3
View File
@@ -72,8 +72,7 @@ Our first modification will be to extract information from the Identity API.
```tsx
// Add identityApiRef to the list of imported from core
import { identityApiRef } from '@backstage/core';
import { useApi } from '@backstage/core-api';
import { identityApiRef, useApi } from '@backstage/core';
```
3. Adjust the ExampleComponent from inline to block
@@ -143,8 +142,8 @@ import {
TableColumn,
Progress,
githubAuthApiRef,
useApi,
} from '@backstage/core';
import { useApi } from '@backstage/core-api';
import { graphql } from '@octokit/graphql';
const ExampleFetchComponent = () => {
-1
View File
@@ -34,7 +34,6 @@
"dependencies": {
"@backstage/catalog-model": "^0.6.0",
"@backstage/core": "^0.4.3",
"@backstage/core-api": "^0.2.7",
"@backstage/plugin-catalog": "^0.2.8",
"@backstage/theme": "^0.2.2",
"@material-ui/core": "^4.11.0",
@@ -14,15 +14,15 @@
* limitations under the License.
*/
import type { Props as RecentWorkflowRunsCardProps } from './RecentWorkflowRunsCard';
import React from 'react';
import { render } from '@testing-library/react';
import { RecentWorkflowRunsCard } from './RecentWorkflowRunsCard';
import { ApiProvider, ApiRegistry, errorApiRef } from '@backstage/core-api';
import { useWorkflowRuns } from '../useWorkflowRuns';
import { ThemeProvider } from '@material-ui/core';
import { ApiProvider, ApiRegistry, errorApiRef } from '@backstage/core';
import { lightTheme } from '@backstage/theme';
import { ThemeProvider } from '@material-ui/core';
import { render } from '@testing-library/react';
import React from 'react';
import { MemoryRouter } from 'react-router';
import { useWorkflowRuns } from '../useWorkflowRuns';
import type { Props as RecentWorkflowRunsCardProps } from './RecentWorkflowRunsCard';
import { RecentWorkflowRunsCard } from './RecentWorkflowRunsCard';
jest.mock('../useWorkflowRuns', () => ({
useWorkflowRuns: jest.fn(),
@@ -14,14 +14,19 @@
* limitations under the License.
*/
import { Entity } from '@backstage/catalog-model';
import { errorApiRef, useApi } from '@backstage/core-api';
import {
EmptyState,
errorApiRef,
InfoCard,
Table,
useApi,
} from '@backstage/core';
import { Button, Link } from '@material-ui/core';
import React, { useEffect } from 'react';
import { generatePath, Link as RouterLink } from 'react-router-dom';
import { GITHUB_ACTIONS_ANNOTATION } from '../useProjectName';
import { useWorkflowRuns } from '../useWorkflowRuns';
import React, { useEffect } from 'react';
import { EmptyState, InfoCard, Table } from '@backstage/core';
import { WorkflowRunStatus } from '../WorkflowRunStatus';
import { Button, Link } from '@material-ui/core';
import { generatePath, Link as RouterLink } from 'react-router-dom';
const firstLine = (message: string): string => message.split('\n')[0];
-1
View File
@@ -34,7 +34,6 @@
"@backstage/catalog-model": "^0.6.0",
"@backstage/config": "^0.1.2",
"@backstage/core": "^0.4.3",
"@backstage/core-api": "^0.2.6",
"@backstage/plugin-catalog": "^0.2.7",
"@backstage/theme": "^0.2.2",
"@material-ui/core": "^4.11.0",
@@ -15,7 +15,7 @@
*/
import React, { PropsWithChildren } from 'react';
import { renderHook } from '@testing-library/react-hooks';
import { ApiProvider, ApiRegistry, errorApiRef } from '@backstage/core-api';
import { ApiProvider, ApiRegistry, errorApiRef } from '@backstage/core';
import { lighthouseApiRef, WebsiteListResponse } from '../api';
import { useWebsiteForEntity } from './useWebsiteForEntity';
import { EntityContext } from '@backstage/plugin-catalog';
@@ -15,7 +15,7 @@
*/
import { useEntity } from '@backstage/plugin-catalog';
import { LIGHTHOUSE_WEBSITE_URL_ANNOTATION } from '../../constants';
import { errorApiRef, useApi } from '@backstage/core-api';
import { errorApiRef, useApi } from '@backstage/core';
import { lighthouseApiRef } from '../api';
import { useAsync } from 'react-use';
-1
View File
@@ -33,7 +33,6 @@
"dependencies": {
"@backstage/catalog-model": "^0.6.0",
"@backstage/core": "^0.4.3",
"@backstage/core-api": "^0.2.8",
"@backstage/plugin-catalog": "^0.2.9",
"@backstage/test-utils": "^0.1.6",
"@backstage/theme": "^0.2.2",
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { ApiProvider, ApiRegistry } from '@backstage/core-api';
import { ApiProvider, ApiRegistry } from '@backstage/core';
import { CatalogApi, catalogApiRef } from '@backstage/plugin-catalog';
import { wrapInTestApp } from '@backstage/test-utils';
import { render } from '@testing-library/react';
@@ -17,7 +17,7 @@ import React from 'react';
import { TechDocsPage } from './TechDocsPage';
import { render, act } from '@testing-library/react';
import { wrapInTestApp } from '@backstage/test-utils';
import { ApiRegistry, ApiProvider } from '@backstage/core-api';
import { ApiRegistry, ApiProvider } from '@backstage/core';
import {
techdocsApiRef,
TechDocsApi,