apply core-imports codemod to all packages and plugins

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-06-17 17:56:24 +02:00
parent 9b9a8f3925
commit d453c05dc3
541 changed files with 1549 additions and 1321 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ import CreateAudit, { CreateAuditContent } from './components/CreateAudit';
import { Entity } from '@backstage/catalog-model';
import { LIGHTHOUSE_WEBSITE_URL_ANNOTATION } from '../constants';
import { AuditListForEntity } from './components/AuditList/AuditListForEntity';
import { MissingAnnotationEmptyState } from '@backstage/core';
import { MissingAnnotationEmptyState } from '@backstage/core-components';
export const isLighthouseAvailable = (entity: Entity) =>
Boolean(entity.metadata.annotations?.[LIGHTHOUSE_WEBSITE_URL_ANNOTATION]);
+1 -1
View File
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import { createApiRef } from '@backstage/core';
import { Config } from '@backstage/config';
import { createApiRef } from '@backstage/core-plugin-api';
export type LighthouseCategoryId =
| 'pwa'
@@ -15,7 +15,6 @@
*/
import { Entity } from '@backstage/catalog-model';
import { ApiProvider, ApiRegistry, errorApiRef } from '@backstage/core';
import { EntityContext } from '@backstage/plugin-catalog-react';
import { lightTheme } from '@backstage/theme';
import { ThemeProvider } from '@material-ui/core';
@@ -31,6 +30,9 @@ import { useWebsiteForEntity } from '../../hooks/useWebsiteForEntity';
import * as data from '../../__fixtures__/website-list-response.json';
import { AuditListForEntity } from './AuditListForEntity';
import { ApiProvider, ApiRegistry } from '@backstage/core-app-api';
import { errorApiRef } from '@backstage/core-plugin-api';
jest.mock('../../hooks/useWebsiteForEntity', () => ({
useWebsiteForEntity: jest.fn(),
}));
@@ -15,8 +15,8 @@
*/
import React from 'react';
import { AuditListTable } from './AuditListTable';
import { Progress } from '@backstage/core';
import { useWebsiteForEntity } from '../../hooks/useWebsiteForEntity';
import { Progress } from '@backstage/core-components';
export const AuditListForEntity = () => {
const { value, loading, error } = useWebsiteForEntity();
@@ -17,9 +17,8 @@
import React from 'react';
import { render } from '@testing-library/react';
import { wrapInTestApp, msw } from '@backstage/test-utils';
import { ApiRegistry, ApiProvider } from '@backstage/core';
import AuditListTable from './AuditListTable';
import {
WebsiteListResponse,
lighthouseApiRef,
@@ -27,9 +26,10 @@ import {
} from '../../api';
import { formatTime } from '../../utils';
import { setupServer } from 'msw/node';
import * as data from '../../__fixtures__/website-list-response.json';
import { ApiRegistry, ApiProvider } from '@backstage/core-app-api';
const websiteListResponse = data as WebsiteListResponse;
describe('AuditListTable', () => {
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import React, { useState, useEffect } from 'react';
import { Table, TableColumn, TrendLine, useApi } from '@backstage/core';
import { Website, lighthouseApiRef } from '../../api';
import { useInterval } from 'react-use';
import {
@@ -26,6 +25,9 @@ import {
import { Link, generatePath } from 'react-router-dom';
import AuditStatusIcon from '../AuditStatusIcon';
import { Table, TableColumn, TrendLine } from '@backstage/core-components';
import { useApi } from '@backstage/core-plugin-api';
const columns: TableColumn[] = [
{
title: 'Website URL',
@@ -23,7 +23,6 @@ jest.mock('react-router-dom', () => {
};
});
import { ApiProvider, ApiRegistry } from '@backstage/core';
import { msw, wrapInTestApp } from '@backstage/test-utils';
import { fireEvent, render } from '@testing-library/react';
import { rest } from 'msw';
@@ -36,6 +35,7 @@ import {
} from '../../api';
import * as data from '../../__fixtures__/website-list-response.json';
import AuditList from './index';
import { ApiProvider, ApiRegistry } from '@backstage/core-app-api';
const { useNavigate } = jest.requireMock('react-router-dom');
const websiteListResponse = data as WebsiteListResponse;
@@ -14,17 +14,6 @@
* limitations under the License.
*/
import {
Content,
ContentHeader,
Header,
HeaderLabel,
InfoCard,
Page,
Progress,
useApi,
WarningPanel,
} from '@backstage/core';
import { Button, Grid } from '@material-ui/core';
import Pagination from '@material-ui/lab/Pagination';
import React, { ReactNode, useMemo, useState } from 'react';
@@ -36,6 +25,19 @@ import LighthouseIntro, { LIGHTHOUSE_INTRO_LOCAL_STORAGE } from '../Intro';
import LighthouseSupportButton from '../SupportButton';
import AuditListTable from './AuditListTable';
import {
Content,
ContentHeader,
Header,
HeaderLabel,
InfoCard,
Page,
Progress,
WarningPanel,
} from '@backstage/core-components';
import { useApi } from '@backstage/core-plugin-api';
// TODO(freben): move all of this out of index
export const LIMIT = 10;
@@ -14,9 +14,13 @@
* limitations under the License.
*/
import { StatusError, StatusOK, StatusPending } from '@backstage/core';
import React from 'react';
import { Audit } from '../../api';
import {
StatusError,
StatusOK,
StatusPending,
} from '@backstage/core-components';
// TODO(freben): move all of this out of index
@@ -26,7 +26,6 @@ jest.mock('react-router-dom', () => {
};
});
import { ApiProvider, ApiRegistry } from '@backstage/core';
import { msw, wrapInTestApp } from '@backstage/test-utils';
import { render } from '@testing-library/react';
import { rest } from 'msw';
@@ -36,6 +35,7 @@ import { Audit, lighthouseApiRef, LighthouseRestApi, Website } from '../../api';
import { formatTime } from '../../utils';
import * as data from '../../__fixtures__/website-response.json';
import AuditView from './index';
import { ApiProvider, ApiRegistry } from '@backstage/core-app-api';
const { useParams }: { useParams: jest.Mock } = jest.requireMock(
'react-router-dom',
@@ -14,16 +14,6 @@
* limitations under the License.
*/
import {
Content,
ContentHeader,
Header,
HeaderLabel,
InfoCard,
Page,
Progress,
useApi,
} from '@backstage/core';
import {
Button,
Grid,
@@ -48,6 +38,17 @@ import { formatTime } from '../../utils';
import AuditStatusIcon from '../AuditStatusIcon';
import LighthouseSupportButton from '../SupportButton';
import {
Content,
ContentHeader,
Header,
HeaderLabel,
InfoCard,
Page,
Progress,
} from '@backstage/core-components';
import { useApi } from '@backstage/core-plugin-api';
// TODO(freben): move all of this out of index
const useStyles = makeStyles({
@@ -13,6 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import { Audit, AuditCompleted, LighthouseCategoryId } from '../../api';
import { useWebsiteForEntity } from '../../hooks/useWebsiteForEntity';
import AuditStatusIcon from '../AuditStatusIcon';
import {
InfoCard,
InfoCardVariants,
@@ -21,11 +25,7 @@ import {
StatusOK,
StatusWarning,
StructuredMetadataTable,
} from '@backstage/core';
import React from 'react';
import { Audit, AuditCompleted, LighthouseCategoryId } from '../../api';
import { useWebsiteForEntity } from '../../hooks/useWebsiteForEntity';
import AuditStatusIcon from '../AuditStatusIcon';
} from '@backstage/core-components';
const LighthouseCategoryScoreStatus = ({ score }: { score: number }) => {
const scoreAsPercentage = Math.round(score * 100);
@@ -23,12 +23,6 @@ jest.mock('react-router-dom', () => {
};
});
import {
ApiProvider,
ApiRegistry,
ErrorApi,
errorApiRef,
} from '@backstage/core';
import { msw, wrapInTestApp } from '@backstage/test-utils';
import { fireEvent, render, waitFor } from '@testing-library/react';
import { rest } from 'msw';
@@ -38,6 +32,9 @@ import { Audit, lighthouseApiRef, LighthouseRestApi } from '../../api';
import * as data from '../../__fixtures__/create-audit-response.json';
import CreateAudit from './index';
import { ApiProvider, ApiRegistry } from '@backstage/core-app-api';
import { ErrorApi, errorApiRef } from '@backstage/core-plugin-api';
const { useNavigate }: { useNavigate: jest.Mock } = jest.requireMock(
'react-router-dom',
);
@@ -14,16 +14,6 @@
* limitations under the License.
*/
import {
Content,
ContentHeader,
errorApiRef,
Header,
HeaderLabel,
InfoCard,
Page,
useApi,
} from '@backstage/core';
import {
Button,
Grid,
@@ -39,6 +29,16 @@ import { lighthouseApiRef } from '../../api';
import { useQuery } from '../../utils';
import LighthouseSupportButton from '../SupportButton';
import {
Content,
ContentHeader,
Header,
HeaderLabel,
InfoCard,
Page,
} from '@backstage/core-components';
import { errorApiRef, useApi } from '@backstage/core-plugin-api';
// TODO(freben): move all of this out of index
const useStyles = makeStyles(theme => ({
@@ -14,12 +14,16 @@
* limitations under the License.
*/
import { ContentHeader, InfoCard, MarkdownContent } from '@backstage/core';
import { Button, Grid, makeStyles, Tab, Tabs } from '@material-ui/core';
import CloseIcon from '@material-ui/icons/Close';
import React, { useState } from 'react';
import { useLocalStorage } from 'react-use';
import LighthouseSupportButton from '../SupportButton';
import {
ContentHeader,
InfoCard,
MarkdownContent,
} from '@backstage/core-components';
// TODO(freben): move all of this out of index
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import React from 'react';
import { SupportButton } from '@backstage/core';
import { SupportButton } from '@backstage/core-components';
export default function LighthouseSupportButton() {
return (
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import { Entity } from '@backstage/catalog-model';
import { ApiProvider, ApiRegistry, errorApiRef } from '@backstage/core';
import { EntityContext } from '@backstage/plugin-catalog-react';
import { renderHook } from '@testing-library/react-hooks';
import React, { PropsWithChildren } from 'react';
@@ -22,6 +21,9 @@ import { lighthouseApiRef, WebsiteListResponse } from '../api';
import * as data from '../__fixtures__/website-list-response.json';
import { useWebsiteForEntity } from './useWebsiteForEntity';
import { ApiProvider, ApiRegistry } from '@backstage/core-app-api';
import { errorApiRef } from '@backstage/core-plugin-api';
const websiteListResponse = data as WebsiteListResponse;
const website = websiteListResponse.items[0];
@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { errorApiRef, useApi } from '@backstage/core';
import { useEntity } from '@backstage/plugin-catalog-react';
import { useAsync } from 'react-use';
import { LIGHTHOUSE_WEBSITE_URL_ANNOTATION } from '../../constants';
import { lighthouseApiRef } from '../api';
import { errorApiRef, useApi } from '@backstage/core-plugin-api';
// For the sake of simplicity we assume that an entity has only one website url. This is to avoid encoding a list
// type in an annotation which is a plain string.
+2 -2
View File
@@ -14,6 +14,7 @@
* limitations under the License.
*/
import { lighthouseApiRef, LighthouseRestApi } from './api';
import {
createPlugin,
createRouteRef,
@@ -21,8 +22,7 @@ import {
configApiRef,
createRoutableExtension,
createComponentExtension,
} from '@backstage/core';
import { lighthouseApiRef, LighthouseRestApi } from './api';
} from '@backstage/core-plugin-api';
export const rootRouteRef = createRouteRef({
path: '',