Additional renamings
Signed-off-by: Erik Engervall <erik.engervall@gmail.com>
This commit is contained in:
@@ -15,41 +15,42 @@
|
||||
*/
|
||||
import React from 'react';
|
||||
import { createDevApp } from '@backstage/dev-utils';
|
||||
|
||||
import {
|
||||
gitHubReleaseManagerPlugin,
|
||||
ReleaseManagerAsAServicePage,
|
||||
GitHubReleaseManagerPage,
|
||||
} from '../src/plugin';
|
||||
|
||||
createDevApp()
|
||||
.registerPlugin(gitHubReleaseManagerPlugin)
|
||||
.addPage({
|
||||
title: 'Page 1',
|
||||
element: (
|
||||
<ReleaseManagerAsAServicePage
|
||||
<GitHubReleaseManagerPage
|
||||
project={{
|
||||
github: {
|
||||
org: 'erikengervall',
|
||||
repo: 'playground',
|
||||
},
|
||||
name: 'ReleaseManagerAsAService (semver)',
|
||||
name: 'GitHub Release Manager (semver)',
|
||||
versioningStrategy: 'semver',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
title: 'Root Page',
|
||||
})
|
||||
.addPage({
|
||||
title: 'Page 2',
|
||||
element: (
|
||||
<ReleaseManagerAsAServicePage
|
||||
<GitHubReleaseManagerPage
|
||||
project={{
|
||||
github: {
|
||||
org: 'erikengervall',
|
||||
repo: 'playground-2',
|
||||
},
|
||||
name: 'ReleaseManagerAsAService (calver)',
|
||||
name: 'GitHub Release Manager (calver)',
|
||||
versioningStrategy: 'calver',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
title: 'Another page',
|
||||
})
|
||||
.render();
|
||||
|
||||
@@ -114,7 +114,9 @@ function Cards({ project, components }: ReleaseManagerAsAServiceProps) {
|
||||
}
|
||||
|
||||
if (gitHubBatchInfo.value === undefined) {
|
||||
return <Alert severity="error">Failed to fetch latest GHE release</Alert>;
|
||||
return (
|
||||
<Alert severity="error">Failed to fetch latest GitHub release</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
if (!gitHubBatchInfo.value.repository.permissions.push) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
} from '../../../test-helpers/test-helpers';
|
||||
import { createRc } from './createRc';
|
||||
|
||||
describe('createGheRc', () => {
|
||||
describe('createRc', () => {
|
||||
beforeEach(jest.clearAllMocks);
|
||||
|
||||
it('should work', async () => {
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
ResponseStep,
|
||||
} from '../../../types/types';
|
||||
import { ApiClient } from '../../../api/ApiClient';
|
||||
import { ReleaseManagerAsAServiceError } from '../../../errors/ReleaseManagerAsAServiceError';
|
||||
import { GitHubReleaseManagerError } from '../../../errors/GitHubReleaseManagerError';
|
||||
|
||||
interface CreateRC {
|
||||
apiClient: ApiClient;
|
||||
@@ -67,7 +67,7 @@ export async function createRc({
|
||||
).createdRef;
|
||||
} catch (error) {
|
||||
if (error.body.message === 'Reference already exists') {
|
||||
throw new ReleaseManagerAsAServiceError(
|
||||
throw new GitHubReleaseManagerError(
|
||||
`Branch "${nextGitHubInfo.rcBranch}" already exists: .../tree/${nextGitHubInfo.rcBranch}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ describe('PatchBody', () => {
|
||||
|
||||
it('should render error', async () => {
|
||||
mockApiClient.getBranch.mockImplementationOnce(() => {
|
||||
throw new Error('lmao hehe');
|
||||
throw new Error('banana');
|
||||
});
|
||||
|
||||
const { getByTestId } = render(
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
ResponseStep,
|
||||
} from '../../../types/types';
|
||||
import { CalverTagParts } from '../../../helpers/tagParts/getCalverTagParts';
|
||||
import { ReleaseManagerAsAServiceError } from '../../../errors/ReleaseManagerAsAServiceError';
|
||||
import { GitHubReleaseManagerError } from '../../../errors/GitHubReleaseManagerError';
|
||||
import { ApiClient } from '../../../api/ApiClient';
|
||||
import { SemverTagParts } from '../../../helpers/tagParts/getSemverTagParts';
|
||||
|
||||
@@ -33,9 +33,7 @@ interface Patch {
|
||||
tagParts: NonNullable<CalverTagParts | SemverTagParts>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inspo: https://stackoverflow.com/questions/53859199/how-to-cherry-pick-through-githubs-api
|
||||
*/
|
||||
// Inspo: https://stackoverflow.com/questions/53859199/how-to-cherry-pick-through-githubs-api
|
||||
export async function patch({
|
||||
apiClient,
|
||||
bumpedTag,
|
||||
@@ -47,7 +45,7 @@ export async function patch({
|
||||
const responseSteps: ResponseStep[] = [];
|
||||
|
||||
if (!selectedPatchCommit || !selectedPatchCommit.sha) {
|
||||
throw new ReleaseManagerAsAServiceError('Invalid commit');
|
||||
throw new GitHubReleaseManagerError('Invalid commit');
|
||||
}
|
||||
|
||||
const releaseBranchName = latestRelease.target_commitish;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
|
||||
import { ApiClient } from '../api/ApiClient';
|
||||
import { ReleaseManagerAsAServiceError } from '../errors/ReleaseManagerAsAServiceError';
|
||||
import { GitHubReleaseManagerError } from '../errors/GitHubReleaseManagerError';
|
||||
|
||||
export const ApiClientContext = createContext<ApiClient | undefined>(undefined);
|
||||
|
||||
@@ -24,7 +24,7 @@ export const useApiClientContext = () => {
|
||||
const apiClient = useContext(ApiClientContext);
|
||||
|
||||
if (!apiClient) {
|
||||
throw new ReleaseManagerAsAServiceError('apiClient not found');
|
||||
throw new GitHubReleaseManagerError('apiClient not found');
|
||||
}
|
||||
|
||||
return apiClient;
|
||||
|
||||
+2
-2
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export class ReleaseManagerAsAServiceError extends Error {
|
||||
export class GitHubReleaseManagerError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
|
||||
this.name = 'ReleaseManagerAsAServiceError';
|
||||
this.name = 'GitHubReleaseManagerError';
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright 2021 Spotify AB
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
import { getNewDate } from './date';
|
||||
|
||||
describe('getNewDate', () => {
|
||||
it('should get a date', () => {
|
||||
const newDate = getNewDate();
|
||||
|
||||
expect(newDate.toISOString()).toMatch(
|
||||
/[\d]{4}-[\d]{2}-[\d]{2}T[\d]{2}:[\d]{2}:[\d]{2}.[\d]{3}Z/,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Copyright 2021 Spotify AB
|
||||
*
|
||||
* 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 const getNewDate = () => new Date();
|
||||
@@ -13,13 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ReleaseManagerAsAServiceError } from '../errors/ReleaseManagerAsAServiceError';
|
||||
import { GitHubReleaseManagerError } from '../errors/GitHubReleaseManagerError';
|
||||
|
||||
export function getShortCommitHash(hash: string) {
|
||||
const shortCommitHash = hash.substr(0, 7);
|
||||
|
||||
if (shortCommitHash.length < 7) {
|
||||
throw new ReleaseManagerAsAServiceError(
|
||||
throw new GitHubReleaseManagerError(
|
||||
'Invalid shortCommitHash: less than 7 characters',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ReleaseManagerAsAServiceError } from '../../errors/ReleaseManagerAsAServiceError';
|
||||
import { GitHubReleaseManagerError } from '../../errors/GitHubReleaseManagerError';
|
||||
|
||||
export type CalverTagParts = {
|
||||
prefix: string;
|
||||
@@ -27,7 +27,7 @@ export function getCalverTagParts(tag: string) {
|
||||
);
|
||||
|
||||
if (result === null || result.length < 4) {
|
||||
throw new ReleaseManagerAsAServiceError('Invalid calver tag');
|
||||
throw new GitHubReleaseManagerError('Invalid calver tag');
|
||||
}
|
||||
|
||||
const tagParts: CalverTagParts = {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { ReleaseManagerAsAServiceError } from '../../errors/ReleaseManagerAsAServiceError';
|
||||
import { GitHubReleaseManagerError } from '../../errors/GitHubReleaseManagerError';
|
||||
|
||||
export type SemverTagParts = {
|
||||
prefix: string;
|
||||
@@ -26,7 +26,7 @@ export function getSemverTagParts(tag: string) {
|
||||
const result = tag.match(/(rc|version)-([0-9]+)\.([0-9]+)\.([0-9]+)/);
|
||||
|
||||
if (result === null || result.length < 4) {
|
||||
throw new ReleaseManagerAsAServiceError('Invalid semver tag');
|
||||
throw new GitHubReleaseManagerError('Invalid semver tag');
|
||||
}
|
||||
|
||||
const tagParts: SemverTagParts = {
|
||||
|
||||
@@ -13,7 +13,4 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {
|
||||
gitHubReleaseManagerPlugin as releaseManagerAsAServicePlugin,
|
||||
ReleaseManagerAsAServicePage,
|
||||
} from './plugin';
|
||||
export { gitHubReleaseManagerPlugin, GitHubReleaseManagerPage } from './plugin';
|
||||
|
||||
@@ -43,7 +43,7 @@ export const gitHubReleaseManagerPlugin = createPlugin({
|
||||
],
|
||||
});
|
||||
|
||||
export const ReleaseManagerAsAServicePage = gitHubReleaseManagerPlugin.provide(
|
||||
export const GitHubReleaseManagerPage = gitHubReleaseManagerPlugin.provide(
|
||||
createRoutableExtension({
|
||||
component: () =>
|
||||
import('./GitHubReleaseManager').then(m => m.ReleaseManagerAsAService),
|
||||
|
||||
Reference in New Issue
Block a user