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
@@ -17,7 +17,6 @@
import React from 'react';
import { useAsync } from 'react-use';
import { Alert } from '@material-ui/lab';
import { useApi, ContentHeader, Progress } from '@backstage/core';
import { Box } from '@material-ui/core';
import {
@@ -35,6 +34,9 @@ import { RepoDetailsForm } from './features/RepoDetailsForm/RepoDetailsForm';
import { useQueryHandler } from './hooks/useQueryHandler';
import { UserContext } from './contexts/UserContext';
import { useApi } from '@backstage/core-plugin-api';
import { ContentHeader, Progress } from '@backstage/core-components';
interface GitReleaseManagerProps {
project?: Omit<Project, 'isProvidedViaProps'>;
features?: {
@@ -14,10 +14,11 @@
* limitations under the License.
*/
import { ConfigReader, OAuthApi } from '@backstage/core';
import { GitReleaseClient } from './GitReleaseClient';
import { ConfigReader } from '@backstage/core-app-api';
import { OAuthApi } from '@backstage/core-plugin-api';
describe('GitReleaseClient', () => {
it('should return the default plugin api client', () => {
const configApi = new ConfigReader({});
@@ -14,14 +14,14 @@
* limitations under the License.
*/
import { ConfigApi, OAuthApi } from '@backstage/core';
import { Octokit } from '@octokit/rest';
import { GitHubIntegration, ScmIntegrations } from '@backstage/integration';
import { DISABLE_CACHE } from '../constants/constants';
import { Project } from '../contexts/ProjectContext';
import { UnboxArray, UnboxReturnedPromise } from '../types/helpers';
import { GitReleaseManagerError } from '../errors/GitReleaseManagerError';
import { ConfigApi, OAuthApi } from '@backstage/core-plugin-api';
export class GitReleaseClient implements GitReleaseApi {
private readonly githubAuthApi: OAuthApi;
@@ -14,10 +14,10 @@
* limitations under the License.
*/
import { createApiRef } from '@backstage/core';
import { GitReleaseApi } from './GitReleaseClient';
import { createApiRef } from '@backstage/core-plugin-api';
export const gitReleaseManagerApiRef = createApiRef<GitReleaseApi>({
id: 'plugin.git-release-manager.service',
description: 'Used by the Git Release Manager plugin to make requests',
@@ -15,11 +15,11 @@
*/
import React from 'react';
import { InfoCard } from '@backstage/core';
import { makeStyles } from '@material-ui/core';
import { TEST_IDS } from '../test-helpers/test-ids';
import { InfoCard } from '@backstage/core-components';
const useStyles = makeStyles(() => ({
feature: {
marginBottom: '3em',
@@ -16,11 +16,11 @@
import React, { PropsWithChildren } from 'react';
import { DialogContent, List } from '@material-ui/core';
import { Progress } from '@backstage/core';
import { ResponseStep } from '../../types/types';
import { ResponseStepListItem } from './ResponseStepListItem';
import { TEST_IDS } from '../../test-helpers/test-ids';
import { Progress } from '@backstage/core-components';
interface ResponseStepListProps {
responseSteps: (ResponseStep | undefined)[];
@@ -16,12 +16,11 @@
import { useEffect, useState } from 'react';
import { useAsync, useAsyncFn } from 'react-use';
import { useApi } from '@backstage/core';
import {
GetLatestReleaseResult,
GetRepositoryResult,
} from '../../../api/GitReleaseClient';
import { CardHook, ComponentConfigCreateRc } from '../../../types/types';
import { getReleaseCandidateGitInfo } from '../../../helpers/getReleaseCandidateGitInfo';
import { gitReleaseManagerApiRef } from '../../../api/serviceApiRef';
@@ -30,6 +29,7 @@ import { Project } from '../../../contexts/ProjectContext';
import { TAG_OBJECT_MESSAGE } from '../../../constants/constants';
import { useResponseSteps } from '../../../hooks/useResponseSteps';
import { useUserContext } from '../../../contexts/UserContext';
import { useApi } from '@backstage/core-plugin-api';
interface UseCreateReleaseCandidate {
defaultBranch: GetRepositoryResult['repository']['defaultBranch'];
@@ -16,7 +16,6 @@
import React, { ComponentProps } from 'react';
import { Alert, AlertTitle } from '@material-ui/lab';
import { ErrorBoundary, Progress, useApi } from '@backstage/core';
import { CreateReleaseCandidate } from './CreateReleaseCandidate/CreateReleaseCandidate';
import { GitReleaseManager } from '../GitReleaseManager';
@@ -30,6 +29,9 @@ import { useProjectContext } from '../contexts/ProjectContext';
import { useVersioningStrategyMatchesRepoTags } from '../hooks/useVersioningStrategyMatchesRepoTags';
import { validateTagName } from '../helpers/tagParts/validateTagName';
import { ErrorBoundary, Progress } from '@backstage/core-components';
import { useApi } from '@backstage/core-plugin-api';
export function Features({
features,
}: {
@@ -28,7 +28,7 @@ import { Stats } from '../Stats/Stats';
import { TEST_IDS } from '../../test-helpers/test-ids';
import { useProjectContext } from '../../contexts/ProjectContext';
import flowImage from './flow.png';
import { Link } from '@backstage/core';
import { Link } from '@backstage/core-components';
interface InfoCardProps {
releaseBranch: GetBranchResult['branch'] | null;
@@ -32,7 +32,6 @@ import {
} from '@material-ui/core';
import FileCopyIcon from '@material-ui/icons/FileCopy';
import OpenInNewIcon from '@material-ui/icons/OpenInNew';
import { Link, Progress, useApi } from '@backstage/core';
import {
GetBranchResult,
@@ -50,6 +49,9 @@ import { TEST_IDS } from '../../test-helpers/test-ids';
import { usePatch } from './hooks/usePatch';
import { useProjectContext } from '../../contexts/ProjectContext';
import { Link, Progress } from '@backstage/core-components';
import { useApi } from '@backstage/core-plugin-api';
interface PatchBodyProps {
bumpedTag: string;
latestRelease: NonNullable<GetLatestReleaseResult['latestRelease']>;
@@ -16,12 +16,11 @@
import { useEffect, useState } from 'react';
import { useAsync, useAsyncFn } from 'react-use';
import { useApi } from '@backstage/core';
import {
GetLatestReleaseResult,
GetRecentCommitsResultSingle,
} from '../../../api/GitReleaseClient';
import { CalverTagParts } from '../../../helpers/tagParts/getCalverTagParts';
import { ComponentConfigPatch, CardHook } from '../../../types/types';
import { getPatchCommitSuffix } from '../helpers/getPatchCommitSuffix';
@@ -31,6 +30,7 @@ import { SemverTagParts } from '../../../helpers/tagParts/getSemverTagParts';
import { TAG_OBJECT_MESSAGE } from '../../../constants/constants';
import { useResponseSteps } from '../../../hooks/useResponseSteps';
import { useUserContext } from '../../../contexts/UserContext';
import { useApi } from '@backstage/core-plugin-api';
interface Patch {
bumpedTag: string;
@@ -16,9 +16,8 @@
import { useState, useEffect } from 'react';
import { useAsync, useAsyncFn } from 'react-use';
import { useApi } from '@backstage/core';
import { CardHook, ComponentConfigPromoteRc } from '../../../types/types';
import { GetLatestReleaseResult } from '../../../api/GitReleaseClient';
import { gitReleaseManagerApiRef } from '../../../api/serviceApiRef';
import { GitReleaseManagerError } from '../../../errors/GitReleaseManagerError';
@@ -26,6 +25,7 @@ import { TAG_OBJECT_MESSAGE } from '../../../constants/constants';
import { useProjectContext } from '../../../contexts/ProjectContext';
import { useResponseSteps } from '../../../hooks/useResponseSteps';
import { useUserContext } from '../../../contexts/UserContext';
import { useApi } from '@backstage/core-plugin-api';
interface PromoteRc {
rcRelease: NonNullable<GetLatestReleaseResult['latestRelease']>;
@@ -25,7 +25,6 @@ import {
Select,
Box,
} from '@material-ui/core';
import { Progress, useApi } from '@backstage/core';
import { gitReleaseManagerApiRef } from '../../api/serviceApiRef';
import { TEST_IDS } from '../../test-helpers/test-ids';
@@ -34,6 +33,9 @@ import { useProjectContext } from '../../contexts/ProjectContext';
import { useQueryHandler } from '../../hooks/useQueryHandler';
import { useUserContext } from '../../contexts/UserContext';
import { Progress } from '@backstage/core-components';
import { useApi } from '@backstage/core-plugin-api';
export function Owner() {
const pluginApiClient = useApi(gitReleaseManagerApiRef);
const { project } = useProjectContext();
@@ -25,7 +25,6 @@ import {
Select,
Box,
} from '@material-ui/core';
import { Progress, useApi } from '@backstage/core';
import { gitReleaseManagerApiRef } from '../../api/serviceApiRef';
import { TEST_IDS } from '../../test-helpers/test-ids';
@@ -33,6 +32,9 @@ import { useFormClasses } from './styles';
import { useProjectContext } from '../../contexts/ProjectContext';
import { useQueryHandler } from '../../hooks/useQueryHandler';
import { Progress } from '@backstage/core-components';
import { useApi } from '@backstage/core-plugin-api';
export function Repo() {
const pluginApiClient = useApi(gitReleaseManagerApiRef);
const { project } = useProjectContext();
@@ -25,9 +25,8 @@ import {
TableHead,
TableRow,
} from '@material-ui/core';
import { Progress } from '@backstage/core';
import { getMappedReleases } from './helpers/getMappedReleases';
import { getReleaseStats } from './helpers/getReleaseStats';
import { Info } from './Info/Info';
import { ReleaseStatsContext } from './contexts/ReleaseStatsContext';
@@ -35,6 +34,7 @@ import { Row } from './Row/Row';
import { useGetStats } from './hooks/useGetStats';
import { useProjectContext } from '../../contexts/ProjectContext';
import { Warn } from './Warn';
import { Progress } from '@backstage/core-components';
const useStyles = makeStyles({
table: {
@@ -17,13 +17,13 @@
import { useEffect, useState } from 'react';
import { useAsync, useAsyncFn } from 'react-use';
import { DateTime } from 'luxon';
import { useApi } from '@backstage/core';
import { getReleaseCommitPairs } from '../helpers/getReleaseCommitPairs';
import { gitReleaseManagerApiRef } from '../../../../api/serviceApiRef';
import { useProjectContext } from '../../../../contexts/ProjectContext';
import { useReleaseStatsContext } from '../../contexts/ReleaseStatsContext';
import { getTagDates } from '../../helpers/getTagDates';
import { useApi } from '@backstage/core-plugin-api';
export type ReleaseCommitPairs = Array<{
baseVersion: string;
@@ -25,10 +25,10 @@ import {
} from '@material-ui/core';
import KeyboardArrowDownIcon from '@material-ui/icons/KeyboardArrowDown';
import ChevronRightIcon from '@material-ui/icons/ChevronRight';
import { Link } from '@backstage/core';
import { ReleaseStats } from '../contexts/ReleaseStatsContext';
import { RowCollapsed } from './RowCollapsed/RowCollapsed';
import { Link } from '@backstage/core-components';
const useRowStyles = makeStyles({
root: {
@@ -19,7 +19,6 @@ import { useAsync } from 'react-use';
import { DateTime } from 'luxon';
import { Box, Typography } from '@material-ui/core';
import { Alert } from '@material-ui/lab';
import { Progress, useApi } from '@backstage/core';
import { getDecimalNumber } from '../../helpers/getDecimalNumber';
import { getTagDates } from '../../helpers/getTagDates';
@@ -27,6 +26,9 @@ import { gitReleaseManagerApiRef } from '../../../../api/serviceApiRef';
import { ReleaseStats } from '../../contexts/ReleaseStatsContext';
import { useProjectContext } from '../../../../contexts/ProjectContext';
import { Progress } from '@backstage/core-components';
import { useApi } from '@backstage/core-plugin-api';
interface ReleaseTimeProps {
releaseStat: ReleaseStats['releases']['0'];
}
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import { useApi } from '@backstage/core';
import { useAsync } from 'react-use';
import { gitReleaseManagerApiRef } from '../../../api/serviceApiRef';
import { useProjectContext } from '../../../contexts/ProjectContext';
import { useApi } from '@backstage/core-plugin-api';
export const useGetStats = () => {
const pluginApiClient = useApi(gitReleaseManagerApiRef);
+5 -5
View File
@@ -14,17 +14,17 @@
* limitations under the License.
*/
import { gitReleaseManagerApiRef } from './api/serviceApiRef';
import { GitReleaseClient } from './api/GitReleaseClient';
import { rootRouteRef } from './routes';
import {
configApiRef,
createPlugin,
createApiFactory,
githubAuthApiRef,
createRoutableExtension,
} from '@backstage/core';
import { gitReleaseManagerApiRef } from './api/serviceApiRef';
import { GitReleaseClient } from './api/GitReleaseClient';
import { rootRouteRef } from './routes';
} from '@backstage/core-plugin-api';
export { gitReleaseManagerApiRef };
+1 -1
View File
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { createRouteRef } from '@backstage/core';
import { createRouteRef } from '@backstage/core-plugin-api';
export const rootRouteRef = createRouteRef({
title: 'git-release-manager',