From 458d16869c028d060be9a009616917fdd53082cb Mon Sep 17 00:00:00 2001 From: Peiman Jafari Date: Wed, 2 Mar 2022 20:44:58 -0800 Subject: [PATCH 01/27] scaffolder-backend: Allow more options in publish:github action Signed-off-by: Peiman Jafari --- .changeset/twenty-fireants-turn.md | 5 +++ .../actions/builtin/publish/github.test.ts | 16 +++++++++ .../actions/builtin/publish/github.ts | 36 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 .changeset/twenty-fireants-turn.md diff --git a/.changeset/twenty-fireants-turn.md b/.changeset/twenty-fireants-turn.md new file mode 100644 index 0000000000..fd9dc17530 --- /dev/null +++ b/.changeset/twenty-fireants-turn.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Allow passing more repo configuration for `publish:github` action diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.test.ts index 1e58635bbe..ec564e93dc 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.test.ts @@ -88,6 +88,10 @@ describe('publish:github', () => { name: 'repo', org: 'owner', private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + allow_merge_commit: true, + allow_rebase_merge: true, visibility: 'private', }); @@ -103,6 +107,10 @@ describe('publish:github', () => { name: 'repo', org: 'owner', private: false, + delete_branch_on_merge: false, + allow_squash_merge: true, + allow_merge_commit: true, + allow_rebase_merge: true, visibility: 'public', }); }); @@ -123,6 +131,10 @@ describe('publish:github', () => { description: 'description', name: 'repo', private: true, + delete_branch_on_merge: false, + allow_squash_merge: true, + allow_merge_commit: true, + allow_rebase_merge: true, }); await action.handler({ @@ -138,6 +150,10 @@ describe('publish:github', () => { description: 'description', name: 'repo', private: false, + delete_branch_on_merge: false, + allow_squash_merge: true, + allow_merge_commit: true, + allow_rebase_merge: true, }); }); diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts index 926a63915a..32969e1be3 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts @@ -46,6 +46,10 @@ export function createPublishGithubAction(options: { description?: string; access?: string; defaultBranch?: string; + deleteBranchOnMerge: boolean; + allowRebaseMerge: boolean; + allowSquashMerge: boolean; + allowMergeCommit: boolean; sourcePath?: string; requireCodeOwnerReviews?: boolean; repoVisibility?: 'private' | 'internal' | 'public'; @@ -94,6 +98,26 @@ export function createPublishGithubAction(options: { type: 'string', description: `Sets the default branch on the repository. The default value is 'master'`, }, + deleteBranchOnMerge: { + title: 'Delete Branch On Merge', + type: 'boolean', + description: `Delete the branch after merging the PR. The default value is 'false'`, + }, + allowMergeCommit: { + title: 'Allow Merge Commits', + type: 'boolean', + description: `Allow merge commits. The default value is 'true'`, + }, + allowSquashMerge: { + title: 'Allow Squash Merges', + type: 'boolean', + description: `Allow squash merges. The default value is 'true'`, + }, + allowRebaseMerge: { + title: 'Allow Rebase Merges', + type: 'boolean', + description: `Allow rebase merges. The default value is 'true'`, + }, sourcePath: { title: 'Source Path', description: @@ -156,6 +180,10 @@ export function createPublishGithubAction(options: { requireCodeOwnerReviews = false, repoVisibility = 'private', defaultBranch = 'master', + deleteBranchOnMerge = false, + allowMergeCommit = true, + allowSquashMerge = true, + allowRebaseMerge = true, collaborators, topics, token: providedToken, @@ -188,11 +216,19 @@ export function createPublishGithubAction(options: { private: repoVisibility === 'private', visibility: repoVisibility, description: description, + delete_branch_on_merge: deleteBranchOnMerge, + allow_merge_commit: allowMergeCommit, + allow_squash_merge: allowSquashMerge, + allow_rebase_merge: allowRebaseMerge, }) : client.rest.repos.createForAuthenticatedUser({ name: repo, private: repoVisibility === 'private', description: description, + delete_branch_on_merge: deleteBranchOnMerge, + allow_merge_commit: allowMergeCommit, + allow_squash_merge: allowSquashMerge, + allow_rebase_merge: allowRebaseMerge, }); const { data: newRepo } = await repoCreationPromise; From 2986f8e09d4d16bf6ddef0678afc3ca93c91c0bb Mon Sep 17 00:00:00 2001 From: Diego Bardari Date: Thu, 3 Mar 2022 10:38:31 +0100 Subject: [PATCH 02/27] Fixed EntityOwnerPicker and OwnershipCard url filter issue Signed-off-by: Diego Bardari --- .changeset/strong-beds-attack.md | 6 ++++++ .../catalog-react/src/hooks/useEntityListProvider.tsx | 2 +- .../Cards/OwnershipCard/OwnershipCard.test.tsx | 4 ++-- .../components/Cards/OwnershipCard/OwnershipCard.tsx | 11 ++++++++--- 4 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 .changeset/strong-beds-attack.md diff --git a/.changeset/strong-beds-attack.md b/.changeset/strong-beds-attack.md new file mode 100644 index 0000000000..f16c709daa --- /dev/null +++ b/.changeset/strong-beds-attack.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-catalog-react': patch +'@backstage/plugin-org': patch +--- + +Fixed EntityOwnerPicker and OwnershipCard url filter issue with more than 21 owners diff --git a/plugins/catalog-react/src/hooks/useEntityListProvider.tsx b/plugins/catalog-react/src/hooks/useEntityListProvider.tsx index f448e41b82..72dfb7d1c3 100644 --- a/plugins/catalog-react/src/hooks/useEntityListProvider.tsx +++ b/plugins/catalog-react/src/hooks/useEntityListProvider.tsx @@ -195,7 +195,7 @@ export const EntityListProvider = ({ }); const newParams = qs.stringify( { ...oldParams, filters: queryParams }, - { addQueryPrefix: true }, + { addQueryPrefix: true, arrayFormat: 'repeat' }, ); const newUrl = `${window.location.pathname}${newParams}`; // We use direct history manipulation since useSearchParams and diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx index 3fc770e6b5..f6aaef6344 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx @@ -248,7 +248,7 @@ describe('OwnershipCard', () => { expect(getByText('OPENAPI').closest('a')).toHaveAttribute( 'href', - '/create/?filters%5Bkind%5D=API&filters%5Btype%5D=openapi&filters%5Bowners%5D%5B0%5D=my-team&filters%5Buser%5D=all', + '/create/?filters%5Bkind%5D=API&filters%5Btype%5D=openapi&filters%5Bowners%5D=my-team&filters%5Buser%5D=all', ); }); @@ -295,7 +295,7 @@ describe('OwnershipCard', () => { expect(getByText('OPENAPI').closest('a')).toHaveAttribute( 'href', - '/create/?filters%5Bkind%5D=API&filters%5Btype%5D=openapi&filters%5Bowners%5D%5B0%5D=user%3Athe-user&filters%5Bowners%5D%5B1%5D=my-team&filters%5Buser%5D=all', + '/create/?filters%5Bkind%5D=API&filters%5Btype%5D=openapi&filters%5Bowners%5D=user%3Athe-user&filters%5Bowners%5D=my-team&filters%5Buser%5D=all', ); }); }); diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx index 2b292cbe8b..1553bcac97 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx @@ -120,9 +120,14 @@ const getQueryParams = ( const user = owner as UserEntity; filters.owners = [...filters.owners, ...user.spec.memberOf]; } - const queryParams = qs.stringify({ - filters, - }); + const queryParams = qs.stringify( + { + filters, + }, + { + arrayFormat: 'repeat', + }, + ); return queryParams; }; From 751418ff8a81f4454934f01b13daa962abe22e33 Mon Sep 17 00:00:00 2001 From: Peiman Jafari Date: Thu, 3 Mar 2022 07:42:27 -0800 Subject: [PATCH 03/27] update mockContext Signed-off-by: Peiman Jafari --- .../src/scaffolder/actions/builtin/publish/github.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.test.ts index ec564e93dc..e997c30a32 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.test.ts @@ -54,6 +54,10 @@ describe('publish:github', () => { description: 'description', repoVisibility: 'private' as const, access: 'owner/blam', + deleteBranchOnMerge: false, + allowMergeCommit: true, + allowSquashMerge: true, + allowRebaseMerge: true, }, workspacePath: 'lol', logger: getVoidLogger(), From c108a04dd116a016147ff7a0733cf03682b81d96 Mon Sep 17 00:00:00 2001 From: Peiman Jafari Date: Thu, 3 Mar 2022 08:22:02 -0800 Subject: [PATCH 04/27] update api-report Signed-off-by: Peiman Jafari --- plugins/scaffolder-backend/api-report.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index 3bc03c4840..3328a11343 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -233,6 +233,10 @@ export function createPublishGithubAction(options: { description?: string | undefined; access?: string | undefined; defaultBranch?: string | undefined; + deleteBranchOnMerge: boolean; + allowRebaseMerge: boolean; + allowSquashMerge: boolean; + allowMergeCommit: boolean; sourcePath?: string | undefined; requireCodeOwnerReviews?: boolean | undefined; repoVisibility?: 'internal' | 'private' | 'public' | undefined; From 7b058b37db2db6e680e696880de2bfc2424ffb56 Mon Sep 17 00:00:00 2001 From: Peiman Jafari Date: Thu, 3 Mar 2022 10:16:43 -0800 Subject: [PATCH 05/27] make new inputs optional Signed-off-by: Peiman Jafari --- plugins/scaffolder-backend/api-report.md | 8 ++++---- .../src/scaffolder/actions/builtin/publish/github.test.ts | 4 ---- .../src/scaffolder/actions/builtin/publish/github.ts | 8 ++++---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index 3328a11343..b18e199f40 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -233,10 +233,10 @@ export function createPublishGithubAction(options: { description?: string | undefined; access?: string | undefined; defaultBranch?: string | undefined; - deleteBranchOnMerge: boolean; - allowRebaseMerge: boolean; - allowSquashMerge: boolean; - allowMergeCommit: boolean; + deleteBranchOnMerge?: boolean | undefined; + allowRebaseMerge?: boolean | undefined; + allowSquashMerge?: boolean | undefined; + allowMergeCommit?: boolean | undefined; sourcePath?: string | undefined; requireCodeOwnerReviews?: boolean | undefined; repoVisibility?: 'internal' | 'private' | 'public' | undefined; diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.test.ts index e997c30a32..ec564e93dc 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.test.ts @@ -54,10 +54,6 @@ describe('publish:github', () => { description: 'description', repoVisibility: 'private' as const, access: 'owner/blam', - deleteBranchOnMerge: false, - allowMergeCommit: true, - allowSquashMerge: true, - allowRebaseMerge: true, }, workspacePath: 'lol', logger: getVoidLogger(), diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts index 32969e1be3..7f1e7a1c93 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts @@ -46,10 +46,10 @@ export function createPublishGithubAction(options: { description?: string; access?: string; defaultBranch?: string; - deleteBranchOnMerge: boolean; - allowRebaseMerge: boolean; - allowSquashMerge: boolean; - allowMergeCommit: boolean; + deleteBranchOnMerge?: boolean; + allowRebaseMerge?: boolean; + allowSquashMerge?: boolean; + allowMergeCommit?: boolean; sourcePath?: string; requireCodeOwnerReviews?: boolean; repoVisibility?: 'private' | 'internal' | 'public'; From d1d488e371ae089fc5941c55643ee53dbac7209c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Thu, 3 Mar 2022 18:49:20 +0100 Subject: [PATCH 06/27] update the common validators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/slow-vans-rhyme.md | 5 +++++ .changeset/ten-rats-join.md | 8 ++++++++ packages/catalog-model/api-report.md | 3 +++ .../entity/policies/FieldFormatEntityPolicy.ts | 3 ++- .../validation/CommonValidatorFunctions.test.ts | 16 ++++++++++++++++ .../src/validation/CommonValidatorFunctions.ts | 13 ++++++++++++- .../src/validation/makeValidator.ts | 11 +++++++++-- 7 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 .changeset/slow-vans-rhyme.md create mode 100644 .changeset/ten-rats-join.md diff --git a/.changeset/slow-vans-rhyme.md b/.changeset/slow-vans-rhyme.md new file mode 100644 index 0000000000..6de924899f --- /dev/null +++ b/.changeset/slow-vans-rhyme.md @@ -0,0 +1,5 @@ +--- +'@backstage/catalog-model': minor +--- + +**BREAKING**: The default validator for `metadata.tags` now permits the colon (`:`) character as well. diff --git a/.changeset/ten-rats-join.md b/.changeset/ten-rats-join.md new file mode 100644 index 0000000000..6aa97be581 --- /dev/null +++ b/.changeset/ten-rats-join.md @@ -0,0 +1,8 @@ +--- +'@backstage/catalog-model': patch +--- + +**DEPRECATION**: + +- Deprecated `CommonValidatorFunctions.isValidString`, please use `isNonEmptyString` instead which is equivalent but better named. +- Deprecated `CommonValidatorFunctions.isValidTag`, with no replacement. Its purpose was too specific and not reusable, so it will be removed. diff --git a/packages/catalog-model/api-report.md b/packages/catalog-model/api-report.md index 99b4b39038..9a65401d55 100644 --- a/packages/catalog-model/api-report.md +++ b/packages/catalog-model/api-report.md @@ -51,6 +51,7 @@ export const apiEntityV1alpha1Validator: KindValidator; // @public export class CommonValidatorFunctions { static isJsonSafe(value: unknown): boolean; + static isNonEmptyString(value: unknown): value is string; static isValidDnsLabel(value: unknown): boolean; static isValidDnsSubdomain(value: unknown): boolean; static isValidPrefixAndOrSuffix( @@ -59,7 +60,9 @@ export class CommonValidatorFunctions { isValidPrefix: (value: string) => boolean, isValidSuffix: (value: string) => boolean, ): boolean; + // @deprecated static isValidString(value: unknown): boolean; + // @deprecated static isValidTag(value: unknown): boolean; static isValidUrl(value: unknown): boolean; } diff --git a/packages/catalog-model/src/entity/policies/FieldFormatEntityPolicy.ts b/packages/catalog-model/src/entity/policies/FieldFormatEntityPolicy.ts index 51059328a6..22d0e5e997 100644 --- a/packages/catalog-model/src/entity/policies/FieldFormatEntityPolicy.ts +++ b/packages/catalog-model/src/entity/policies/FieldFormatEntityPolicy.ts @@ -95,6 +95,7 @@ export class FieldFormatEntityPolicy implements EntityPolicy { expectation = 'a string that is a valid url'; break; case 'isValidString': + case 'isNonEmptyString': expectation = 'a non empty string'; break; default: @@ -156,7 +157,7 @@ export class FieldFormatEntityPolicy implements EntityPolicy { optional( `links.${i}.title`, links[i]?.title, - CommonValidatorFunctions.isValidString, + CommonValidatorFunctions.isNonEmptyString, ); optional( `links.${i}.icon`, diff --git a/packages/catalog-model/src/validation/CommonValidatorFunctions.test.ts b/packages/catalog-model/src/validation/CommonValidatorFunctions.test.ts index 88e3f9b002..9a9ec8bcda 100644 --- a/packages/catalog-model/src/validation/CommonValidatorFunctions.test.ts +++ b/packages/catalog-model/src/validation/CommonValidatorFunctions.test.ts @@ -226,4 +226,20 @@ describe('CommonValidatorFunctions', () => { ])(`isValidString %p ? %p`, (value, result) => { expect(CommonValidatorFunctions.isValidString(value)).toBe(result); }); + + it.each([ + [null, false], + [true, false], + [7, false], + [{}, false], + ['', false], + [' ', false], + [' ', false], + ['abc', true], + [' abc ', true], + ['abc xyz', true], + ['abc xyz abc.', true], + ])(`isNonEmptyString %p ? %p`, (value, result) => { + expect(CommonValidatorFunctions.isNonEmptyString(value)).toBe(result); + }); }); diff --git a/packages/catalog-model/src/validation/CommonValidatorFunctions.ts b/packages/catalog-model/src/validation/CommonValidatorFunctions.ts index d0357660fc..8c814412c1 100644 --- a/packages/catalog-model/src/validation/CommonValidatorFunctions.ts +++ b/packages/catalog-model/src/validation/CommonValidatorFunctions.ts @@ -98,6 +98,7 @@ export class CommonValidatorFunctions { /** * Checks that the value is a valid tag. * + * @deprecated This will be removed in a future release * @param value - The value to check */ static isValidTag(value: unknown): boolean { @@ -110,7 +111,7 @@ export class CommonValidatorFunctions { } /** - * Checks that the value is a valid URL. + * Checks that the value is a valid string URL. * * @param value - The value to check */ @@ -131,9 +132,19 @@ export class CommonValidatorFunctions { /** * Checks that the value is a non empty string value. * + * @deprecated use isNonEmptyString instead * @param value - The value to check */ static isValidString(value: unknown): boolean { return typeof value === 'string' && value?.trim()?.length >= 1; } + + /** + * Checks that the value is a string value that's not empty. + * + * @param value - The value to check + */ + static isNonEmptyString(value: unknown): value is string { + return typeof value === 'string' && value?.trim()?.length >= 1; + } } diff --git a/packages/catalog-model/src/validation/makeValidator.ts b/packages/catalog-model/src/validation/makeValidator.ts index ad3f52e563..c3c7182680 100644 --- a/packages/catalog-model/src/validation/makeValidator.ts +++ b/packages/catalog-model/src/validation/makeValidator.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { CommonValidatorFunctions } from './CommonValidatorFunctions'; import { KubernetesValidatorFunctions } from './KubernetesValidatorFunctions'; import { Validators } from './types'; @@ -27,7 +26,15 @@ const defaultValidators: Validators = { isValidLabelValue: KubernetesValidatorFunctions.isValidLabelValue, isValidAnnotationKey: KubernetesValidatorFunctions.isValidAnnotationKey, isValidAnnotationValue: KubernetesValidatorFunctions.isValidAnnotationValue, - isValidTag: CommonValidatorFunctions.isValidTag, + isValidTag: (value: unknown): boolean => { + // NOTE(freben): This one is a bit of an oddball and doesn't fit well anywhere to delegate to, so it's just inlined for now. + return ( + typeof value === 'string' && + value.length >= 1 && + value.length <= 63 && + /^[a-z0-9:+#]+(\-[a-z0-9:+#]+)*$/.test(value) + ); + }, }; /** From f06da37290e6a0567da120cc3d2a862e7544b505 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 3 Mar 2022 20:14:05 +0100 Subject: [PATCH 07/27] cli: always use main entry point in packages for backend development Signed-off-by: Patrik Oldsberg --- .changeset/spotty-swans-run.md | 5 +++++ packages/cli/src/lib/bundler/config.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/spotty-swans-run.md diff --git a/.changeset/spotty-swans-run.md b/.changeset/spotty-swans-run.md new file mode 100644 index 0000000000..7a16343d69 --- /dev/null +++ b/.changeset/spotty-swans-run.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +The backend development setup now ignores the `"browser"` and `"module"` entry points in `package.json`, and instead always uses `"main"`. diff --git a/packages/cli/src/lib/bundler/config.ts b/packages/cli/src/lib/bundler/config.ts index bfd05807ad..575af4ea8b 100644 --- a/packages/cli/src/lib/bundler/config.ts +++ b/packages/cli/src/lib/bundler/config.ts @@ -272,7 +272,7 @@ export async function createBackendConfig( ], resolve: { extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx'], - mainFields: ['browser', 'module', 'main'], + mainFields: ['main'], modules: [paths.rootNodeModules, ...moduleDirs], plugins: [ new LinkedPackageResolvePlugin(paths.rootNodeModules, externalPkgs), From d3d1b82198d2974bd078e02d071d6bff87165bad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Mar 2022 04:13:11 +0000 Subject: [PATCH 08/27] chore(deps): bump minimatch from 5.0.0 to 5.0.1 Bumps [minimatch](https://github.com/isaacs/minimatch) from 5.0.0 to 5.0.1. - [Release notes](https://github.com/isaacs/minimatch/releases) - [Commits](https://github.com/isaacs/minimatch/compare/v5.0.0...v5.0.1) --- updated-dependencies: - dependency-name: minimatch dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .changeset/dependabot-4014eb7.md | 5 +++++ packages/cli/package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 .changeset/dependabot-4014eb7.md diff --git a/.changeset/dependabot-4014eb7.md b/.changeset/dependabot-4014eb7.md new file mode 100644 index 0000000000..7b4d64523a --- /dev/null +++ b/.changeset/dependabot-4014eb7.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +chore(deps): bump `minimatch` from 5.0.0 to 5.0.1 diff --git a/packages/cli/package.json b/packages/cli/package.json index 26b941c699..af2c3afb2d 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -89,7 +89,7 @@ "json-schema": "^0.4.0", "jest-transform-yaml": "^1.0.0", "lodash": "^4.17.21", - "minimatch": "5.0.0", + "minimatch": "5.0.1", "mini-css-extract-plugin": "^2.4.2", "npm-packlist": "^3.0.0", "node-libs-browser": "^2.2.1", diff --git a/yarn.lock b/yarn.lock index 48784ac13c..e599c0ca31 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17906,10 +17906,10 @@ minimatch@3.0.4, minimatch@^3.0.2, minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" -minimatch@5.0.0, minimatch@^5.0.0: - version "5.0.0" - resolved "https://registry.npmjs.org/minimatch/-/minimatch-5.0.0.tgz#281d8402aaaeed18a9e8406ad99c46a19206c6ef" - integrity sha512-EU+GCVjXD00yOUf1TwAHVP7v3fBD3A8RkkPYsWWKGWesxM/572sL53wJQnHxquHlRhYUV36wHkqrN8cdikKc2g== +minimatch@5.0.1, minimatch@^5.0.0: + version "5.0.1" + resolved "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz#fb9022f7528125187c92bd9e9b6366be1cf3415b" + integrity sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g== dependencies: brace-expansion "^2.0.1" From 23568dd328a7cf3879eda51d176e3aac42f2ae5b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Mar 2022 04:13:40 +0000 Subject: [PATCH 09/27] chore(deps): bump @react-hookz/web from 12.3.0 to 13.0.0 Bumps [@react-hookz/web](https://github.com/react-hookz/web) from 12.3.0 to 13.0.0. - [Release notes](https://github.com/react-hookz/web/releases) - [Changelog](https://github.com/react-hookz/web/blob/master/CHANGELOG.md) - [Commits](https://github.com/react-hookz/web/compare/v12.3.0...v13.0.0) --- updated-dependencies: - dependency-name: "@react-hookz/web" dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .changeset/dependabot-ae5fb9c.md | 6 ++++++ packages/core-components/package.json | 2 +- plugins/gcp-projects/package.json | 2 +- yarn.lock | 7 +++++++ 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .changeset/dependabot-ae5fb9c.md diff --git a/.changeset/dependabot-ae5fb9c.md b/.changeset/dependabot-ae5fb9c.md new file mode 100644 index 0000000000..5648da2be7 --- /dev/null +++ b/.changeset/dependabot-ae5fb9c.md @@ -0,0 +1,6 @@ +--- +'@backstage/core-components': patch +'@backstage/plugin-gcp-projects': patch +--- + +chore(deps): bump `@react-hookz/web` from 12.3.0 to 13.0.0 diff --git a/packages/core-components/package.json b/packages/core-components/package.json index 93fa015b89..4e896fd178 100644 --- a/packages/core-components/package.json +++ b/packages/core-components/package.json @@ -65,7 +65,7 @@ "react-syntax-highlighter": "^15.4.5", "react-text-truncate": "^0.18.0", "react-use": "^17.3.2", - "@react-hookz/web": "^12.3.0", + "@react-hookz/web": "^13.0.0", "react-virtualized-auto-sizer": "^1.0.6", "react-window": "^1.8.6", "remark-gfm": "^3.0.1", diff --git a/plugins/gcp-projects/package.json b/plugins/gcp-projects/package.json index 3cb3be5382..b56565ab22 100644 --- a/plugins/gcp-projects/package.json +++ b/plugins/gcp-projects/package.json @@ -41,7 +41,7 @@ "@material-ui/icons": "^4.9.1", "@material-ui/lab": "4.0.0-alpha.57", "react-router-dom": "6.0.0-beta.0", - "@react-hookz/web": "^12.3.0" + "@react-hookz/web": "^13.0.0" }, "peerDependencies": { "react": "^16.13.1 || ^17.0.0" diff --git a/yarn.lock b/yarn.lock index 48784ac13c..5f6da29a39 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4851,6 +4851,13 @@ dependencies: "@react-hookz/deep-equal" "^1.0.1" +"@react-hookz/web@^13.0.0": + version "13.0.0" + resolved "https://registry.npmjs.org/@react-hookz/web/-/web-13.0.0.tgz#7c4d54fb4c1edf885879914d719e35086964e46e" + integrity sha512-sAMTOiOnAvxpJtHea7Vk+2+KJdTC/o77wPII+glnH+astNUSSiduptLaMPeoIXXwqjfJT+IJ9JzWyZPrLpdyFw== + dependencies: + "@react-hookz/deep-equal" "^1.0.1" + "@rjsf/core@^3.2.1": version "3.2.1" resolved "https://registry.npmjs.org/@rjsf/core/-/core-3.2.1.tgz#8a7b24c9a6f01f0ecb093fdfc777172c12b1b009" From 5ea9509e6a048101a9d029b80e9a95b8debb416b Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Fri, 4 Mar 2022 11:23:47 +0100 Subject: [PATCH 10/27] catalog: Remove CatalogResultListItem Signed-off-by: Johan Haals --- .changeset/fifty-brooms-whisper.md | 5 +++++ .../CatalogSearchResultListItem.tsx | 12 ------------ .../components/CatalogSearchResultListItem/index.ts | 10 ++-------- 3 files changed, 7 insertions(+), 20 deletions(-) create mode 100644 .changeset/fifty-brooms-whisper.md diff --git a/.changeset/fifty-brooms-whisper.md b/.changeset/fifty-brooms-whisper.md new file mode 100644 index 0000000000..b4c45555a3 --- /dev/null +++ b/.changeset/fifty-brooms-whisper.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': minor +--- + +**BREAKING**: Removed `CatalogResultListItemProps` and `CatalogResultListItem`, replaced by `CatalogSearchResultListItemProps` and `CatalogSearchResultListItem`. diff --git a/plugins/catalog/src/components/CatalogSearchResultListItem/CatalogSearchResultListItem.tsx b/plugins/catalog/src/components/CatalogSearchResultListItem/CatalogSearchResultListItem.tsx index 54cfe43364..9762eb3da9 100644 --- a/plugins/catalog/src/components/CatalogSearchResultListItem/CatalogSearchResultListItem.tsx +++ b/plugins/catalog/src/components/CatalogSearchResultListItem/CatalogSearchResultListItem.tsx @@ -73,15 +73,3 @@ export function CatalogSearchResultListItem( ); } - -/** - * @public - * @deprecated use {@link CatalogSearchResultListItemProps} instead - */ -export type CatalogResultListItemProps = CatalogSearchResultListItemProps; - -/** - * @public - * @deprecated use {@link CatalogSearchResultListItem} instead - */ -export const CatalogResultListItem = CatalogSearchResultListItem; diff --git a/plugins/catalog/src/components/CatalogSearchResultListItem/index.ts b/plugins/catalog/src/components/CatalogSearchResultListItem/index.ts index 0396117825..ba0e6d29be 100644 --- a/plugins/catalog/src/components/CatalogSearchResultListItem/index.ts +++ b/plugins/catalog/src/components/CatalogSearchResultListItem/index.ts @@ -14,11 +14,5 @@ * limitations under the License. */ -export { - CatalogSearchResultListItem, - CatalogResultListItem, -} from './CatalogSearchResultListItem'; -export type { - CatalogSearchResultListItemProps, - CatalogResultListItemProps, -} from './CatalogSearchResultListItem'; +export { CatalogSearchResultListItem } from './CatalogSearchResultListItem'; +export type { CatalogSearchResultListItemProps } from './CatalogSearchResultListItem'; From e4aee4e08f0eb077c1a3126fc60a6f2bdc2921e2 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Fri, 4 Mar 2022 11:24:33 +0100 Subject: [PATCH 11/27] Update api report Signed-off-by: Johan Haals --- plugins/catalog/api-report.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/plugins/catalog/api-report.md b/plugins/catalog/api-report.md index 97a36ad020..f95b7b1682 100644 --- a/plugins/catalog/api-report.md +++ b/plugins/catalog/api-report.md @@ -104,12 +104,6 @@ export const catalogPlugin: BackstagePlugin< } >; -// @public @deprecated (undocumented) -export const CatalogResultListItem: typeof CatalogSearchResultListItem; - -// @public @deprecated (undocumented) -export type CatalogResultListItemProps = CatalogSearchResultListItemProps; - // @public (undocumented) export function CatalogSearchResultListItem( props: CatalogSearchResultListItemProps, From 1201383b6069915f333d00d6364eb1218b25d77a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 4 Mar 2022 11:22:52 +0100 Subject: [PATCH 12/27] create-app: switch to storing release version in backstage.json Signed-off-by: Patrik Oldsberg --- .changeset/olive-roses-sleep.md | 5 +++++ packages/create-app/src/createApp.test.ts | 6 +++--- packages/create-app/src/createApp.ts | 6 +++--- packages/create-app/src/index.ts | 2 +- packages/create-app/src/lib/tasks.test.ts | 5 +++-- packages/create-app/src/lib/tasks.ts | 9 --------- packages/create-app/src/lib/versions.ts | 3 +++ .../create-app/templates/default-app/backstage.json.hbs | 3 +++ 8 files changed, 21 insertions(+), 18 deletions(-) create mode 100644 .changeset/olive-roses-sleep.md create mode 100644 packages/create-app/templates/default-app/backstage.json.hbs diff --git a/.changeset/olive-roses-sleep.md b/.changeset/olive-roses-sleep.md new file mode 100644 index 0000000000..b402a5b2aa --- /dev/null +++ b/.changeset/olive-roses-sleep.md @@ -0,0 +1,5 @@ +--- +'@backstage/create-app': patch +--- + +Updated the template to write the Backstage release version to `backstage.json`, rather than the version of `@backstage/create-app`. This change is applied automatically when running `backstage-cli versions:bump` in the latest version of the Backstage CLI. diff --git a/packages/create-app/src/createApp.test.ts b/packages/create-app/src/createApp.test.ts index ee01e8fd42..09099e2d15 100644 --- a/packages/create-app/src/createApp.test.ts +++ b/packages/create-app/src/createApp.test.ts @@ -59,7 +59,7 @@ describe('command entrypoint', () => { test('should call expected tasks with no path option', async () => { const cmd = {} as unknown as Command; - await createApp(cmd, '1.0.0'); + await createApp(cmd); expect(checkAppExistsMock).toHaveBeenCalled(); expect(createTemporaryAppFolderMock).toHaveBeenCalled(); expect(templatingMock).toHaveBeenCalled(); @@ -69,7 +69,7 @@ describe('command entrypoint', () => { it('should call expected tasks with path option', async () => { const cmd = { path: 'myDirectory' } as unknown as Command; - await createApp(cmd, '1.0.0'); + await createApp(cmd); expect(checkPathExistsMock).toHaveBeenCalled(); expect(templatingMock).toHaveBeenCalled(); expect(buildAppMock).toHaveBeenCalled(); @@ -77,7 +77,7 @@ describe('command entrypoint', () => { it('should not call `buildAppTask` when `skipInstall` is supplied', async () => { const cmd = { skipInstall: true } as unknown as Command; - await createApp(cmd, '1.0.0'); + await createApp(cmd); expect(buildAppMock).not.toHaveBeenCalled(); }); }); diff --git a/packages/create-app/src/createApp.ts b/packages/create-app/src/createApp.ts index d4d30364dc..36143a4172 100644 --- a/packages/create-app/src/createApp.ts +++ b/packages/create-app/src/createApp.ts @@ -30,7 +30,7 @@ import { templatingTask, } from './lib/tasks'; -export default async (cmd: Command, version: string): Promise => { +export default async (cmd: Command): Promise => { /* eslint-disable-next-line no-restricted-syntax */ const paths = findPaths(__dirname); @@ -80,7 +80,7 @@ export default async (cmd: Command, version: string): Promise => { await checkPathExistsTask(appDir); Task.section('Preparing files'); - await templatingTask(templateDir, cmd.path, answers, version); + await templatingTask(templateDir, cmd.path, answers); } else { // Template to temporary location, and then move files @@ -91,7 +91,7 @@ export default async (cmd: Command, version: string): Promise => { await createTemporaryAppFolderTask(tempDir); Task.section('Preparing files'); - await templatingTask(templateDir, tempDir, answers, version); + await templatingTask(templateDir, tempDir, answers); Task.section('Moving to final location'); await moveAppTask(tempDir, appDir, answers.name); diff --git a/packages/create-app/src/index.ts b/packages/create-app/src/index.ts index 8a2da2fad8..a8ff3dc9b9 100644 --- a/packages/create-app/src/index.ts +++ b/packages/create-app/src/index.ts @@ -38,7 +38,7 @@ const main = (argv: string[]) => { '--skip-install', 'Skip the install and builds steps after creating the app', ) - .action(cmd => createApp(cmd, version)); + .action(cmd => createApp(cmd)); program.parse(argv); }; diff --git a/packages/create-app/src/lib/tasks.test.ts b/packages/create-app/src/lib/tasks.test.ts index d7b4692aa4..0c92173dbf 100644 --- a/packages/create-app/src/lib/tasks.test.ts +++ b/packages/create-app/src/lib/tasks.test.ts @@ -18,6 +18,7 @@ import fs from 'fs-extra'; import mockFs from 'mock-fs'; import child_process from 'child_process'; import path from 'path'; +import { version as releaseVersion } from '../../../../package.json'; import { buildAppTask, checkAppExistsTask, @@ -195,11 +196,11 @@ describe('templatingTask', () => { name: 'SuperCoolBackstageInstance', dbTypeSqlite: true, }; - await templatingTask(templateDir, destinationDir, context, '1.0.0'); + await templatingTask(templateDir, destinationDir, context); expect(fs.existsSync('templatedApp/package.json')).toBe(true); expect(fs.existsSync('templatedApp/.dockerignore')).toBe(true); await expect(fs.readJson('templatedApp/backstage.json')).resolves.toEqual({ - version: '1.0.0', + version: releaseVersion, }); // catalog was populated with `context.name` expect( diff --git a/packages/create-app/src/lib/tasks.ts b/packages/create-app/src/lib/tasks.ts index 4bd7050fc2..1650432969 100644 --- a/packages/create-app/src/lib/tasks.ts +++ b/packages/create-app/src/lib/tasks.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { BACKSTAGE_JSON } from '@backstage/cli-common'; import chalk from 'chalk'; import fs from 'fs-extra'; import handlebars from 'handlebars'; @@ -23,7 +22,6 @@ import recursive from 'recursive-readdir'; import { basename, dirname, - join, resolve as resolvePath, relative as relativePath, } from 'path'; @@ -86,7 +84,6 @@ export async function templatingTask( templateDir: string, destinationDir: string, context: any, - version: string, ) { const files = await recursive(templateDir).catch(error => { throw new Error(`Failed to read template directory: ${error.message}`); @@ -136,12 +133,6 @@ export async function templatingTask( }); } } - await Task.forItem('creating', BACKSTAGE_JSON, () => - fs.writeFile( - join(destinationDir, BACKSTAGE_JSON), - `{\n "version": ${JSON.stringify(version)}\n}\n`, - ), - ); } /** diff --git a/packages/create-app/src/lib/versions.ts b/packages/create-app/src/lib/versions.ts index 7179b7924f..3c898f1e02 100644 --- a/packages/create-app/src/lib/versions.ts +++ b/packages/create-app/src/lib/versions.ts @@ -30,6 +30,8 @@ Rollup will extract the value of the version field in each package at build time leaving any imports in place. */ +import { version as root } from '../../../../package.json'; + import { version as appDefaults } from '../../../app-defaults/package.json'; import { version as backendCommon } from '../../../backend-common/package.json'; import { version as backendTasks } from '../../../backend-tasks/package.json'; @@ -75,6 +77,7 @@ import { version as pluginTechdocsBackend } from '../../../../plugins/techdocs-b import { version as pluginUserSettings } from '../../../../plugins/user-settings/package.json'; export const packageVersions = { + root, '@backstage/app-defaults': appDefaults, '@backstage/backend-common': backendCommon, '@backstage/backend-tasks': backendTasks, diff --git a/packages/create-app/templates/default-app/backstage.json.hbs b/packages/create-app/templates/default-app/backstage.json.hbs new file mode 100644 index 0000000000..2aa00ecaee --- /dev/null +++ b/packages/create-app/templates/default-app/backstage.json.hbs @@ -0,0 +1,3 @@ +{ + "version": "{{version 'root'}}" +} From 51856359bffff8a45212feaea55160c7613d062f Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Fri, 4 Mar 2022 11:41:27 +0100 Subject: [PATCH 13/27] catalog: Remove AboutCard Signed-off-by: Johan Haals --- .changeset/brown-points-impress.md | 5 +++++ plugins/catalog/api-report.md | 3 --- plugins/catalog/src/components/AboutCard/AboutCard.tsx | 3 +-- plugins/catalog/src/index.ts | 7 ++++++- 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 .changeset/brown-points-impress.md diff --git a/.changeset/brown-points-impress.md b/.changeset/brown-points-impress.md new file mode 100644 index 0000000000..74d5e1019d --- /dev/null +++ b/.changeset/brown-points-impress.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': minor +--- + +**BREAKING**: Removed the `AboutCard` component which has been replaced by `EntityAboutCard`. diff --git a/plugins/catalog/api-report.md b/plugins/catalog/api-report.md index 97a36ad020..7cfa8a581f 100644 --- a/plugins/catalog/api-report.md +++ b/plugins/catalog/api-report.md @@ -26,9 +26,6 @@ import { TableProps } from '@backstage/core-components'; import { TabProps } from '@material-ui/core'; import { UserListFilterKind } from '@backstage/plugin-catalog-react'; -// @public @deprecated (undocumented) -export function AboutCard(props: AboutCardProps): JSX.Element; - // @public export interface AboutCardProps { // (undocumented) diff --git a/plugins/catalog/src/components/AboutCard/AboutCard.tsx b/plugins/catalog/src/components/AboutCard/AboutCard.tsx index 55cef5a5bd..b634c999f9 100644 --- a/plugins/catalog/src/components/AboutCard/AboutCard.tsx +++ b/plugins/catalog/src/components/AboutCard/AboutCard.tsx @@ -72,7 +72,7 @@ const useStyles = makeStyles({ }); /** - * Props for {@link AboutCard}. + * Props for {@link EntityAboutCard}. * * @public */ @@ -82,7 +82,6 @@ export interface AboutCardProps { /** * @public - * @deprecated Please use EntityAboutCard instead */ export function AboutCard(props: AboutCardProps) { const { variant } = props; diff --git a/plugins/catalog/src/index.ts b/plugins/catalog/src/index.ts index 662a920f8b..cfe4851d09 100644 --- a/plugins/catalog/src/index.ts +++ b/plugins/catalog/src/index.ts @@ -22,7 +22,12 @@ export * from './apis'; -export * from './components/AboutCard'; +export type { + AboutCardProps, + AboutContentProps, + AboutFieldProps, +} from './components/AboutCard'; +export { AboutContent, AboutField } from './components/AboutCard'; export * from './components/CatalogKindHeader'; export * from './components/CatalogSearchResultListItem'; export * from './components/CatalogTable'; From 1549c4be2e98f475cc8157ca01fba0a27de4103f Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Fri, 4 Mar 2022 11:51:22 +0100 Subject: [PATCH 14/27] update comment Signed-off-by: Johan Haals --- plugins/catalog/src/components/AboutCard/AboutCard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/catalog/src/components/AboutCard/AboutCard.tsx b/plugins/catalog/src/components/AboutCard/AboutCard.tsx index b634c999f9..b7ccd49b31 100644 --- a/plugins/catalog/src/components/AboutCard/AboutCard.tsx +++ b/plugins/catalog/src/components/AboutCard/AboutCard.tsx @@ -81,7 +81,7 @@ export interface AboutCardProps { } /** - * @public + * Exported publicly via the EntityAboutCard */ export function AboutCard(props: AboutCardProps) { const { variant } = props; From 8e426f464a10df3c297e4bf98dc08c7d449a0723 Mon Sep 17 00:00:00 2001 From: Simon Stamm Date: Fri, 4 Mar 2022 11:35:44 +0100 Subject: [PATCH 15/27] add TUI Group to adopters list Signed-off-by: Simon Stamm --- ADOPTERS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ADOPTERS.md b/ADOPTERS.md index 83a8886d3f..5aad5dcf72 100644 --- a/ADOPTERS.md +++ b/ADOPTERS.md @@ -102,3 +102,4 @@ _If you're using Backstage in your organization, please try to add your company | [Grupo Boticário](https://www.grupoboticario.com.br/) | [@chicoribas](https://github.com/chicoribas), [@fndiaz](https://github.com/fndiaz), [@digogid](https://github.com/digogid), [@manumbs](https://github.com/manumbs), [@haooliveira84](https://github.com/haooliveira84), [@Rhullyam](https://github.com/Rhullyam) | Centralized developer portal with catalog, documentation, and software templates to build a ready to go application, including pipelines (CI/CD) and cloud services provisioning | | [Snyk](https://snyk.io/) | [@robcresswell](https://github.com/robcresswell) | Developer portal for software discovery, API documentation and templating | | [Stilingue](https://www.stilingue.com.br/) | [@stilingue-inteligencia-artificial](https://github.com/Stilingue-IA), [@bbviana](https://github.com/bbviana) | Developer portal, services catalog and centralization of metrics from Grafana, Sentry and GCP. Furthermore, centralization of documentation and infra details like DNS, Network services, SSL and so on. | +| [TUI Group](https://www.tuigroup.com/) | [Simon Stamm](https://github.com/simonstamm), [Christian Rudolph](https://github.com/ChrisRu82) | Developer portal for all engineer to provide discoverability to all internal components, APIs, documentation and to scaffold templates with integrations to our internal tools extended by plugins from our community. | From ae9d6fb3df355bf0f36b062b823ef796a1b3867d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Fri, 4 Mar 2022 12:14:48 +0100 Subject: [PATCH 16/27] remove createDatabase and SingleConnectionDatabaseManager that were deprecated years ago :) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/thick-games-dress.md | 8 ++ .../tutorials/configuring-plugin-databases.md | 23 ----- packages/backend-common/api-report.md | 6 -- .../src/database/SingleConnection.test.ts | 99 ------------------- .../src/database/SingleConnection.ts | 28 ------ .../backend-common/src/database/connection.ts | 8 -- packages/backend-common/src/database/index.ts | 7 +- 7 files changed, 9 insertions(+), 170 deletions(-) create mode 100644 .changeset/thick-games-dress.md delete mode 100644 packages/backend-common/src/database/SingleConnection.test.ts delete mode 100644 packages/backend-common/src/database/SingleConnection.ts diff --git a/.changeset/thick-games-dress.md b/.changeset/thick-games-dress.md new file mode 100644 index 0000000000..5ce2decd3f --- /dev/null +++ b/.changeset/thick-games-dress.md @@ -0,0 +1,8 @@ +--- +'@backstage/backend-common': minor +--- + +**BREAKING**: + +- Removed the (since way back) deprecated `createDatabase` export, please use `createDatabaseClient` instead. +- Removed the (since way back) deprecated `SingleConnectionDatabaseManager` export, please use `DatabaseManager` instead. diff --git a/docs/tutorials/configuring-plugin-databases.md b/docs/tutorials/configuring-plugin-databases.md index 5c5f0ffb68..9277bb5028 100644 --- a/docs/tutorials/configuring-plugin-databases.md +++ b/docs/tutorials/configuring-plugin-databases.md @@ -49,29 +49,6 @@ yarn add sqlite3 From an operational perspective, you only need to install drivers for clients that are actively used. -### Database Manager - -Existing Backstage instances should be updated to use `DatabaseManager` from -`@backstage/backend-common` in your `packages/backend/src/index.ts` file, the -`SingleConnectionDatabaseManager` has been deprecated. Import the manager and -update the references as shown below if this is not the case: - -```diff -import { -- SingleConnectionDatabaseManager, -+ DatabaseManager, -} from '@backstage/backend-common'; - -// ... - -function makeCreateEnv(config: Config) { - // ... -- const databaseManager = SingleConnectionDatabaseManager.fromConfig(config); -+ const databaseManager = DatabaseManager.fromConfig(config); - // ... -} -``` - ## Configuration You should set the base database client and connection information in your diff --git a/packages/backend-common/api-report.md b/packages/backend-common/api-report.md index 4ed9bb1514..f9fd164787 100644 --- a/packages/backend-common/api-report.md +++ b/packages/backend-common/api-report.md @@ -170,9 +170,6 @@ export class Contexts { ): Context; } -// @public @deprecated -export const createDatabase: typeof createDatabaseClient; - // @public export function createDatabaseClient( dbConfig: Config, @@ -574,9 +571,6 @@ export type ServiceBuilder = { // @public export function setRootLogger(newLogger: winston.Logger): void; -// @public @deprecated -export const SingleConnectionDatabaseManager: typeof DatabaseManager; - // @public export class SingleHostDiscovery implements PluginEndpointDiscovery { static fromConfig( diff --git a/packages/backend-common/src/database/SingleConnection.test.ts b/packages/backend-common/src/database/SingleConnection.test.ts deleted file mode 100644 index 46d7376d25..0000000000 --- a/packages/backend-common/src/database/SingleConnection.test.ts +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2020 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. - */ - -import { ConfigReader } from '@backstage/config'; -import { createDatabaseClient, ensureDatabaseExists } from './connection'; -import { SingleConnectionDatabaseManager } from './SingleConnection'; - -jest.mock('./connection', () => ({ - ...jest.requireActual('./connection'), - createDatabaseClient: jest.fn(), - ensureDatabaseExists: jest.fn(), -})); - -describe('SingleConnectionDatabaseManager', () => { - const defaultConfigOptions = { - backend: { - database: { - client: 'pg', - connection: { - host: 'localhost', - user: 'foo', - password: 'bar', - database: 'foodb', - }, - }, - }, - }; - const defaultConfig = () => new ConfigReader(defaultConfigOptions); - - // This is similar to the ts-jest `mocked` helper. - const mocked = (f: Function) => f as jest.Mock; - - afterEach(() => jest.resetAllMocks()); - - describe('SingleConnectionDatabaseManager.fromConfig', () => { - it('accesses the backend.database key', () => { - const config = defaultConfig(); - const getConfig = jest.spyOn(config, 'getConfig'); - - SingleConnectionDatabaseManager.fromConfig(config); - - expect(getConfig.mock.calls[0][0]).toEqual('backend.database'); - }); - }); - - describe('SingleConnectionDatabaseManager.forPlugin', () => { - const manager = SingleConnectionDatabaseManager.fromConfig(defaultConfig()); - - it('connects to a database scoped to the plugin', async () => { - const pluginId = 'test1'; - await manager.forPlugin(pluginId).getClient(); - - expect(mocked(createDatabaseClient)).toHaveBeenCalledTimes(1); - - const mockCalls = mocked(createDatabaseClient).mock.calls.splice(-1); - const callArgs = mockCalls[0]; - expect(callArgs[1].connection.database).toEqual( - `backstage_plugin_${pluginId}`, - ); - }); - - it('provides different plugins different databases', async () => { - const plugin1Id = 'test1'; - const plugin2Id = 'test2'; - await manager.forPlugin(plugin1Id).getClient(); - await manager.forPlugin(plugin2Id).getClient(); - - expect(mocked(createDatabaseClient)).toHaveBeenCalledTimes(2); - - const mockCalls = mocked(createDatabaseClient).mock.calls; - const plugin1CallArgs = mockCalls[0]; - const plugin2CallArgs = mockCalls[1]; - expect(plugin1CallArgs[1].connection.database).not.toEqual( - plugin2CallArgs[1].connection.database, - ); - }); - - it('ensure plugin database is created', async () => { - await manager.forPlugin('test').getClient(); - const mockCalls = mocked(ensureDatabaseExists).mock.calls.splice(-1); - const [_, database] = mockCalls[0]; - - expect(database).toEqual('backstage_plugin_test'); - }); - }); -}); diff --git a/packages/backend-common/src/database/SingleConnection.ts b/packages/backend-common/src/database/SingleConnection.ts deleted file mode 100644 index a81d60fe83..0000000000 --- a/packages/backend-common/src/database/SingleConnection.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2020 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. - */ - -import { DatabaseManager } from './DatabaseManager'; - -/** - * Implements a Database Manager which will automatically create new databases - * for plugins when requested. All requested databases are created with the - * credentials provided; if the database already exists no attempt to create - * the database will be made. - * - * @public - * @deprecated Use `DatabaseManager` from `@backend-common` instead. - */ -export const SingleConnectionDatabaseManager = DatabaseManager; diff --git a/packages/backend-common/src/database/connection.ts b/packages/backend-common/src/database/connection.ts index 7fc9df060d..fd0769b8a2 100644 --- a/packages/backend-common/src/database/connection.ts +++ b/packages/backend-common/src/database/connection.ts @@ -57,14 +57,6 @@ export function createDatabaseClient( ); } -/** - * Alias for {@link createDatabaseClient} - * - * @public - * @deprecated Use createDatabaseClient instead - */ -export const createDatabase = createDatabaseClient; - /** * Ensures that the given databases all exist, creating them if they do not. * diff --git a/packages/backend-common/src/database/index.ts b/packages/backend-common/src/database/index.ts index 2a820f7367..0dde1ec239 100644 --- a/packages/backend-common/src/database/index.ts +++ b/packages/backend-common/src/database/index.ts @@ -14,18 +14,13 @@ * limitations under the License. */ -export * from './SingleConnection'; export * from './DatabaseManager'; /* * Undocumented API surface from connection is being reduced for future deprecation. * Avoid exporting additional symbols. */ -export { - createDatabaseClient, - createDatabase, - ensureDatabaseExists, -} from './connection'; +export { createDatabaseClient, ensureDatabaseExists } from './connection'; export type { PluginDatabaseManager } from './types'; export { isDatabaseConflictError } from './util'; From dc98ba469d550b51194e3681f94f7b1f24feeac0 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 4 Mar 2022 10:30:11 +0100 Subject: [PATCH 17/27] cli: fix release stage entry point resolution Signed-off-by: Patrik Oldsberg --- packages/cli/src/commands/pack.ts | 11 ++++++++--- packages/cli/src/lib/packager/copyPackageDist.ts | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/commands/pack.ts b/packages/cli/src/commands/pack.ts index e646568980..6c88ac055f 100644 --- a/packages/cli/src/commands/pack.ts +++ b/packages/cli/src/commands/pack.ts @@ -23,6 +23,11 @@ const SKIPPED_KEYS = ['access', 'registry', 'tag', 'alphaTypes', 'betaTypes']; const PKG_PATH = 'package.json'; const PKG_BACKUP_PATH = 'package.json-prepack'; +function resolveEntrypoint(pkg: any, name: string) { + const targetEntry = pkg.publishConfig[name] || pkg[name]; + return targetEntry && joinPath('..', targetEntry); +} + // Writes e.g. alpha/package.json async function writeReleaseStageEntrypoint(pkg: any, stage: 'alpha' | 'beta') { await fs.ensureDir(paths.resolveTarget(stage)); @@ -31,9 +36,9 @@ async function writeReleaseStageEntrypoint(pkg: any, stage: 'alpha' | 'beta') { { name: pkg.name, version: pkg.version, - main: (pkg.publishConfig.main || pkg.main) && '..', - module: (pkg.publishConfig.module || pkg.module) && '..', - browser: (pkg.publishConfig.browser || pkg.browser) && '..', + main: resolveEntrypoint(pkg, 'main'), + module: resolveEntrypoint(pkg, 'module'), + browser: resolveEntrypoint(pkg, 'browser'), types: joinPath('..', pkg.publishConfig[`${stage}Types`]), }, { encoding: 'utf8', spaces: 2 }, diff --git a/packages/cli/src/lib/packager/copyPackageDist.ts b/packages/cli/src/lib/packager/copyPackageDist.ts index 03ac361006..439b087fd7 100644 --- a/packages/cli/src/lib/packager/copyPackageDist.ts +++ b/packages/cli/src/lib/packager/copyPackageDist.ts @@ -20,6 +20,11 @@ import { join as joinPath, resolve as resolvePath } from 'path'; const SKIPPED_KEYS = ['access', 'registry', 'tag', 'alphaTypes', 'betaTypes']; +function resolveEntrypoint(pkg: any, name: string) { + const targetEntry = pkg.publishConfig[name] || pkg[name]; + return targetEntry && joinPath('..', targetEntry); +} + // Writes e.g. alpha/package.json async function writeReleaseStageEntrypoint( pkg: any, @@ -32,9 +37,9 @@ async function writeReleaseStageEntrypoint( { name: pkg.name, version: pkg.version, - main: (pkg.publishConfig.main || pkg.main) && '..', - module: (pkg.publishConfig.module || pkg.module) && '..', - browser: (pkg.publishConfig.browser || pkg.browser) && '..', + main: resolveEntrypoint(pkg, 'main'), + module: resolveEntrypoint(pkg, 'module'), + browser: resolveEntrypoint(pkg, 'browser'), types: joinPath('..', pkg.publishConfig[`${stage}Types`]), }, { encoding: 'utf8', spaces: 2 }, From f833dd823c1c59e4cdd2fb61e48f4d3299b8e253 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 4 Mar 2022 10:31:33 +0100 Subject: [PATCH 18/27] catalog-backend: mark github multi org reader as stable Signed-off-by: Patrik Oldsberg --- plugins/catalog-backend/api-report.md | 2 +- .../src/modules/github/GithubMultiOrgReaderProcessor.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/catalog-backend/api-report.md b/plugins/catalog-backend/api-report.md index 0d9f306009..fcbd124e3a 100644 --- a/plugins/catalog-backend/api-report.md +++ b/plugins/catalog-backend/api-report.md @@ -706,7 +706,7 @@ export type GithubMultiOrgConfig = Array<{ userNamespace: string | undefined; }>; -// @alpha +// @public export class GithubMultiOrgReaderProcessor implements CatalogProcessor { constructor(options: { integrations: ScmIntegrationRegistry; diff --git a/plugins/catalog-backend/src/modules/github/GithubMultiOrgReaderProcessor.ts b/plugins/catalog-backend/src/modules/github/GithubMultiOrgReaderProcessor.ts index 339119137a..dbd858fc0d 100644 --- a/plugins/catalog-backend/src/modules/github/GithubMultiOrgReaderProcessor.ts +++ b/plugins/catalog-backend/src/modules/github/GithubMultiOrgReaderProcessor.ts @@ -40,10 +40,11 @@ import { import { buildOrgHierarchy } from '../util/org'; /** - * @alpha * Extracts teams and users out of a multiple GitHub orgs namespaced per org. * * Be aware that this processor may not be compatible with future org structures in the catalog. + * + * @public */ export class GithubMultiOrgReaderProcessor implements CatalogProcessor { private readonly integrations: ScmIntegrationRegistry; From b1aacbf96a8064442ac049743ab4da3b3a317610 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 4 Mar 2022 12:55:49 +0100 Subject: [PATCH 19/27] Applied patches from 0.70.1 release Signed-off-by: Patrik Oldsberg --- .changeset/patched.json | 9 ++++++++- .changeset/popular-boxes-develop.md | 5 +++++ .changeset/popular-rats-return.md | 9 +++++++++ packages/backend-common/CHANGELOG.md | 6 ++++++ packages/catalog-model/CHANGELOG.md | 6 ++++++ packages/cli/CHANGELOG.md | 6 ++++++ plugins/catalog-backend/CHANGELOG.md | 11 +++++++++++ plugins/catalog-common/CHANGELOG.md | 6 ++++++ plugins/catalog-react/CHANGELOG.md | 8 ++++++++ 9 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 .changeset/popular-boxes-develop.md create mode 100644 .changeset/popular-rats-return.md diff --git a/.changeset/patched.json b/.changeset/patched.json index 1029c8f106..dd63e86169 100644 --- a/.changeset/patched.json +++ b/.changeset/patched.json @@ -1,3 +1,10 @@ { - "currentReleaseVersion": {} + "currentReleaseVersion": { + "@backstage/backend-common": "0.12.1", + "@backstage/catalog-model": "0.12.1", + "@backstage/cli": "0.15.1", + "@backstage/plugin-catalog-backend": "0.23.1", + "@backstage/plugin-catalog-common": "0.2.1", + "@backstage/plugin-catalog-react": "0.8.1" + } } diff --git a/.changeset/popular-boxes-develop.md b/.changeset/popular-boxes-develop.md new file mode 100644 index 0000000000..65aae2c7df --- /dev/null +++ b/.changeset/popular-boxes-develop.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Applied the fix from version `0.15.1` of this package, which was part of the `v0.70.1` release of Backstage. diff --git a/.changeset/popular-rats-return.md b/.changeset/popular-rats-return.md new file mode 100644 index 0000000000..3a91e6d707 --- /dev/null +++ b/.changeset/popular-rats-return.md @@ -0,0 +1,9 @@ +--- +'@backstage/backend-common': patch +'@backstage/catalog-model': patch +'@backstage/plugin-catalog-backend': patch +'@backstage/plugin-catalog-common': patch +'@backstage/plugin-catalog-react': patch +--- + +Applied the fix for the `/alpha` entry point resolution that was part of the `v0.70.1` release of Backstage. diff --git a/packages/backend-common/CHANGELOG.md b/packages/backend-common/CHANGELOG.md index 8a7b5ef528..70b2455a55 100644 --- a/packages/backend-common/CHANGELOG.md +++ b/packages/backend-common/CHANGELOG.md @@ -1,5 +1,11 @@ # @backstage/backend-common +## 0.12.1 + +### Patch Changes + +- Fixed runtime resolution of the `/alpha` entry point. + ## 0.12.0 ### Minor Changes diff --git a/packages/catalog-model/CHANGELOG.md b/packages/catalog-model/CHANGELOG.md index 72d4f8b04a..bea5f18f09 100644 --- a/packages/catalog-model/CHANGELOG.md +++ b/packages/catalog-model/CHANGELOG.md @@ -1,5 +1,11 @@ # @backstage/catalog-model +## 0.12.1 + +### Patch Changes + +- Fixed runtime resolution of the `/alpha` entry point. + ## 0.12.0 ### Minor Changes diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index cfae3cab06..10f7ce1d69 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,11 @@ # @backstage/cli +## 0.15.1 + +### Patch Changes + +- Fixed an issue where the release stage entry point of packages were not resolved correctly. + ## 0.15.0 ### Minor Changes diff --git a/plugins/catalog-backend/CHANGELOG.md b/plugins/catalog-backend/CHANGELOG.md index fb197a65f5..d4a7d8b8d6 100644 --- a/plugins/catalog-backend/CHANGELOG.md +++ b/plugins/catalog-backend/CHANGELOG.md @@ -1,5 +1,16 @@ # @backstage/plugin-catalog-backend +## 0.23.1 + +### Patch Changes + +- Marked `GithubMultiOrgReaderProcessor` as stable, as it was moved to `/alpha` by mistake. +- Fixed runtime resolution of the `/alpha` entry point. +- Updated dependencies + - @backstage/backend-common@0.12.1 + - @backstage/catalog-model@0.12.1 + - @backstage/plugin-catalog-common@0.2.1 + ## 0.23.0 ### Minor Changes diff --git a/plugins/catalog-common/CHANGELOG.md b/plugins/catalog-common/CHANGELOG.md index 707207eda4..badffd5f0a 100644 --- a/plugins/catalog-common/CHANGELOG.md +++ b/plugins/catalog-common/CHANGELOG.md @@ -1,5 +1,11 @@ # @backstage/plugin-catalog-common +## 0.2.1 + +### Patch Changes + +- Fixed runtime resolution of the `/alpha` entry point. + ## 0.2.0 ### Minor Changes diff --git a/plugins/catalog-react/CHANGELOG.md b/plugins/catalog-react/CHANGELOG.md index 89e03aa445..b93a2f7451 100644 --- a/plugins/catalog-react/CHANGELOG.md +++ b/plugins/catalog-react/CHANGELOG.md @@ -1,5 +1,13 @@ # @backstage/plugin-catalog-react +## 0.8.1 + +### Patch Changes + +- Fixed runtime resolution of the `/alpha` entry point. +- Updated dependencies + - @backstage/catalog-model@0.12.1 + ## 0.8.0 ### Minor Changes From b0af81726d17a005c12a860a1861be150d57e1a9 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Fri, 4 Mar 2022 13:39:26 +0100 Subject: [PATCH 20/27] catalog-react: Remove reduceCatalogFilters & reduceEntityFilters Signed-off-by: Johan Haals --- .changeset/chilly-comics-jam.md | 5 +++++ plugins/catalog-react/api-report.md | 10 ---------- plugins/catalog-react/src/index.ts | 9 ++++++++- plugins/catalog-react/src/utils/filters.ts | 8 -------- 4 files changed, 13 insertions(+), 19 deletions(-) create mode 100644 .changeset/chilly-comics-jam.md diff --git a/.changeset/chilly-comics-jam.md b/.changeset/chilly-comics-jam.md new file mode 100644 index 0000000000..92d7f9014e --- /dev/null +++ b/.changeset/chilly-comics-jam.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-react': minor +--- + +**BREAKING**: Removed `reduceCatalogFilters` and `reduceEntityFilters` due to low external utility value. diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index ca5de26048..6d6d4ecc27 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -477,16 +477,6 @@ export class MockStarredEntitiesApi implements StarredEntitiesApi { toggleStarred(entityRef: string): Promise; } -// @public @deprecated (undocumented) -export function reduceCatalogFilters( - filters: EntityFilter[], -): Record; - -// @public @deprecated (undocumented) -export function reduceEntityFilters( - filters: EntityFilter[], -): (entity: Entity) => boolean; - // @public export interface StarredEntitiesApi { starredEntitie$(): Observable>; diff --git a/plugins/catalog-react/src/index.ts b/plugins/catalog-react/src/index.ts index 2279d49a2c..6d5a5ad204 100644 --- a/plugins/catalog-react/src/index.ts +++ b/plugins/catalog-react/src/index.ts @@ -30,5 +30,12 @@ export * from './filters'; export { entityRouteParams, entityRouteRef } from './routes'; export * from './testUtils'; export * from './types'; -export * from './utils'; export * from './overridableComponents'; +export { + getEntityMetadataEditUrl, + getEntityMetadataViewUrl, + getEntityRelations, + getEntitySourceLocation, + isOwnerOf, +} from './utils'; +export type { EntitySourceLocation } from './utils'; diff --git a/plugins/catalog-react/src/utils/filters.ts b/plugins/catalog-react/src/utils/filters.ts index 68cd94fd6e..109e864c52 100644 --- a/plugins/catalog-react/src/utils/filters.ts +++ b/plugins/catalog-react/src/utils/filters.ts @@ -17,10 +17,6 @@ import { Entity } from '@backstage/catalog-model'; import { EntityFilter } from '../types'; -/** - * @public - * @deprecated will be made private. - */ export function reduceCatalogFilters( filters: EntityFilter[], ): Record { @@ -32,10 +28,6 @@ export function reduceCatalogFilters( }, {} as Record); } -/** - * @public - * @deprecated will be made private. - */ export function reduceEntityFilters( filters: EntityFilter[], ): (entity: Entity) => boolean { From a3eb3d2afaf85259607a969810009222eaa78b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Fri, 4 Mar 2022 13:25:23 +0100 Subject: [PATCH 21/27] remove getXByEntity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/two-mails-boil.md | 5 +++ packages/catalog-client/api-report.md | 10 ----- packages/catalog-client/src/CatalogClient.ts | 45 -------------------- 3 files changed, 5 insertions(+), 55 deletions(-) create mode 100644 .changeset/two-mails-boil.md diff --git a/.changeset/two-mails-boil.md b/.changeset/two-mails-boil.md new file mode 100644 index 0000000000..22651f1bd4 --- /dev/null +++ b/.changeset/two-mails-boil.md @@ -0,0 +1,5 @@ +--- +'@backstage/catalog-client': minor +--- + +**BREAKING**: Removed `CatalogClient.getLocationByEntity` and `CatalogClient.getOriginLocationByEntity` which had previously been deprecated. Please use `CatalogApi.getLocationByRef` instead. Note that this only affects you if you were using `CatalogClient` (the class) directly, rather than `CatalogApi` (the interface), since it has been removed from the interface in an earlier release. diff --git a/packages/catalog-client/api-report.md b/packages/catalog-client/api-report.md index 9bbb24463b..d85b9c4d0d 100644 --- a/packages/catalog-client/api-report.md +++ b/packages/catalog-client/api-report.md @@ -107,11 +107,6 @@ export class CatalogClient implements CatalogApi { request: GetEntityFacetsRequest, options?: CatalogRequestOptions, ): Promise; - // @deprecated (undocumented) - getLocationByEntity( - entity: Entity, - options?: CatalogRequestOptions, - ): Promise; getLocationById( id: string, options?: CatalogRequestOptions, @@ -120,11 +115,6 @@ export class CatalogClient implements CatalogApi { locationRef: string, options?: CatalogRequestOptions, ): Promise; - // @deprecated (undocumented) - getOriginLocationByEntity( - entity: Entity, - options?: CatalogRequestOptions, - ): Promise; refreshEntity( entityRef: string, options?: CatalogRequestOptions, diff --git a/packages/catalog-client/src/CatalogClient.ts b/packages/catalog-client/src/CatalogClient.ts index f2bc3ed8f6..53397d061e 100644 --- a/packages/catalog-client/src/CatalogClient.ts +++ b/packages/catalog-client/src/CatalogClient.ts @@ -15,8 +15,6 @@ */ import { - ANNOTATION_LOCATION, - ANNOTATION_ORIGIN_LOCATION, Entity, CompoundEntityRef, parseEntityRef, @@ -308,49 +306,6 @@ export class CatalogClient implements CatalogApi { }; } - /** - * @deprecated please use getLocationByRef instead - */ - async getOriginLocationByEntity( - entity: Entity, - options?: CatalogRequestOptions, - ): Promise { - const locationCompound = - entity.metadata.annotations?.[ANNOTATION_ORIGIN_LOCATION]; - if (!locationCompound) { - return undefined; - } - const all: { data: Location }[] = await this.requestRequired( - 'GET', - '/locations', - options, - ); - return all - .map(r => r.data) - .find(l => locationCompound === stringifyLocationRef(l)); - } - - /** - * @deprecated please use getLocationByRef instead - */ - async getLocationByEntity( - entity: Entity, - options?: CatalogRequestOptions, - ): Promise { - const locationCompound = entity.metadata.annotations?.[ANNOTATION_LOCATION]; - if (!locationCompound) { - return undefined; - } - const all: { data: Location }[] = await this.requestRequired( - 'GET', - '/locations', - options, - ); - return all - .map(r => r.data) - .find(l => locationCompound === stringifyLocationRef(l)); - } - /** * {@inheritdoc CatalogApi.getLocationByRef} */ From c382100444c8a0018f7890ca6c67afa2b85e66cb Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Fri, 4 Mar 2022 13:53:49 +0100 Subject: [PATCH 22/27] catalog-react: Remove useEntityCompoundName Signed-off-by: Johan Haals --- plugins/catalog-react/src/hooks/index.ts | 1 - plugins/catalog-react/src/hooks/useEntity.tsx | 10 ++++--- .../src/hooks/useEntityCompoundName.ts | 27 ------------------- .../components/EntityLayout/EntityLayout.tsx | 5 ++-- plugins/rollbar/src/hooks/useCatalogEntity.ts | 9 +++---- 5 files changed, 13 insertions(+), 39 deletions(-) delete mode 100644 plugins/catalog-react/src/hooks/useEntityCompoundName.ts diff --git a/plugins/catalog-react/src/hooks/index.ts b/plugins/catalog-react/src/hooks/index.ts index da23d54ad7..907dad973b 100644 --- a/plugins/catalog-react/src/hooks/index.ts +++ b/plugins/catalog-react/src/hooks/index.ts @@ -25,7 +25,6 @@ export type { EntityProviderProps, AsyncEntityProviderProps, } from './useEntity'; -export { useEntityCompoundName } from './useEntityCompoundName'; export { EntityListContext, EntityListProvider, diff --git a/plugins/catalog-react/src/hooks/useEntity.tsx b/plugins/catalog-react/src/hooks/useEntity.tsx index f80f858dec..152c1ebe61 100644 --- a/plugins/catalog-react/src/hooks/useEntity.tsx +++ b/plugins/catalog-react/src/hooks/useEntity.tsx @@ -14,7 +14,11 @@ * limitations under the License. */ import { Entity } from '@backstage/catalog-model'; -import { errorApiRef, useApi } from '@backstage/core-plugin-api'; +import { + errorApiRef, + useApi, + useRouteRefParams, +} from '@backstage/core-plugin-api'; import { createVersionedContext, createVersionedValueMap, @@ -24,7 +28,7 @@ import React, { ReactNode, useEffect } from 'react'; import { useNavigate } from 'react-router'; import useAsyncRetry from 'react-use/lib/useAsyncRetry'; import { catalogApiRef } from '../api'; -import { useEntityCompoundName } from './useEntityCompoundName'; +import { entityRouteRef } from '../routes'; /** @public */ export type EntityLoadingStatus = { @@ -104,7 +108,7 @@ export const EntityProvider = ({ entity, children }: EntityProviderProps) => ( * @deprecated will be deleted shortly due to low external usage, re-implement if needed. */ export const useEntityFromUrl = (): EntityLoadingStatus => { - const { kind, namespace, name } = useEntityCompoundName(); + const { kind, namespace, name } = useRouteRefParams(entityRouteRef); const navigate = useNavigate(); const errorApi = useApi(errorApiRef); const catalogApi = useApi(catalogApiRef); diff --git a/plugins/catalog-react/src/hooks/useEntityCompoundName.ts b/plugins/catalog-react/src/hooks/useEntityCompoundName.ts deleted file mode 100644 index 481c18f8a0..0000000000 --- a/plugins/catalog-react/src/hooks/useEntityCompoundName.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2020 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. - */ -import { entityRouteRef } from '../routes'; -import { useRouteRefParams } from '@backstage/core-plugin-api'; - -/** - * Grabs entity kind, namespace, and name from the location - * @public - * @deprecated use {@link @backstage/core-plugin-api#useRouteRefParams} instead - */ -export const useEntityCompoundName = () => { - const { kind, namespace, name } = useRouteRefParams(entityRouteRef); - return { kind, namespace, name }; -}; diff --git a/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx b/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx index 40c4f9e873..d4244419cb 100644 --- a/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx +++ b/plugins/catalog/src/components/EntityLayout/EntityLayout.tsx @@ -33,15 +33,16 @@ import { attachComponentData, IconComponent, useElementFilter, + useRouteRefParams, } from '@backstage/core-plugin-api'; import { EntityRefLinks, + entityRouteRef, FavoriteEntity, getEntityRelations, InspectEntityDialog, UnregisterEntityDialog, useAsyncEntity, - useEntityCompoundName, } from '@backstage/plugin-catalog-react'; import { Box, TabProps } from '@material-ui/core'; import { Alert } from '@material-ui/lab'; @@ -176,7 +177,7 @@ export const EntityLayout = (props: EntityLayoutProps) => { UNSTABLE_contextMenuOptions, children, } = props; - const { kind, namespace, name } = useEntityCompoundName(); + const { kind, namespace, name } = useRouteRefParams(entityRouteRef); const { entity, loading, error } = useAsyncEntity(); const location = useLocation(); const routes = useElementFilter( diff --git a/plugins/rollbar/src/hooks/useCatalogEntity.ts b/plugins/rollbar/src/hooks/useCatalogEntity.ts index 21d22dd13c..4845a275be 100644 --- a/plugins/rollbar/src/hooks/useCatalogEntity.ts +++ b/plugins/rollbar/src/hooks/useCatalogEntity.ts @@ -14,16 +14,13 @@ * limitations under the License. */ -import { - catalogApiRef, - useEntityCompoundName, -} from '@backstage/plugin-catalog-react'; +import { catalogApiRef, entityRouteRef } from '@backstage/plugin-catalog-react'; import useAsync from 'react-use/lib/useAsync'; -import { useApi } from '@backstage/core-plugin-api'; +import { useApi, useRouteRefParams } from '@backstage/core-plugin-api'; export function useCatalogEntity() { const catalogApi = useApi(catalogApiRef); - const { namespace, name } = useEntityCompoundName(); + const { namespace, name } = useRouteRefParams(entityRouteRef); const { value: entity, From 9844d4d2bd739324cac8c98445b8ea3700febbd6 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Fri, 4 Mar 2022 13:56:44 +0100 Subject: [PATCH 23/27] changesets Signed-off-by: Johan Haals --- .changeset/nasty-seahorses-bathe.md | 6 ++++++ .changeset/nice-windows-push.md | 5 +++++ 2 files changed, 11 insertions(+) create mode 100644 .changeset/nasty-seahorses-bathe.md create mode 100644 .changeset/nice-windows-push.md diff --git a/.changeset/nasty-seahorses-bathe.md b/.changeset/nasty-seahorses-bathe.md new file mode 100644 index 0000000000..884313e422 --- /dev/null +++ b/.changeset/nasty-seahorses-bathe.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-catalog': patch +'@backstage/plugin-rollbar': patch +--- + +Removed usage of removed hook. diff --git a/.changeset/nice-windows-push.md b/.changeset/nice-windows-push.md new file mode 100644 index 0000000000..2d04141cf1 --- /dev/null +++ b/.changeset/nice-windows-push.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-react': minor +--- + +**BREAKING**: Removed `useEntityCompoundName`, use `useRouteRefParams(entityRouteRef)` instead. From 5247f613ca9881157384c08a53c7bb29cd54a497 Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Fri, 4 Mar 2022 13:57:35 +0100 Subject: [PATCH 24/27] update api report Signed-off-by: Johan Haals --- plugins/catalog-react/api-report.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index ca5de26048..42ceb29571 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -522,13 +522,6 @@ export function useEntity(): { refresh?: VoidFunction; }; -// @public @deprecated -export const useEntityCompoundName: () => { - kind: string; - namespace: string; - name: string; -}; - // @public @deprecated (undocumented) export const useEntityFromUrl: () => EntityLoadingStatus; From 2b8c986ce0a84c4cfc33001d318a97dfc714874b Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Fri, 4 Mar 2022 14:06:34 +0100 Subject: [PATCH 25/27] catalog-react: Remove useEntityListProvider Signed-off-by: Johan Haals --- .changeset/quiet-pens-wait.md | 5 +++++ plugins/catalog-react/api-report.md | 5 ----- plugins/catalog-react/src/hooks/index.ts | 1 - .../src/hooks/useEntityListProvider.tsx | 14 -------------- 4 files changed, 5 insertions(+), 20 deletions(-) create mode 100644 .changeset/quiet-pens-wait.md diff --git a/.changeset/quiet-pens-wait.md b/.changeset/quiet-pens-wait.md new file mode 100644 index 0000000000..b7510eab3f --- /dev/null +++ b/.changeset/quiet-pens-wait.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-react': minor +--- + +**BREAKING**: Removed `useEntityListProvider` use `useEntityList` instead. diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index ca5de26048..ceedf9fe1a 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -544,11 +544,6 @@ export function useEntityList< EntityFilters extends DefaultEntityFilters = DefaultEntityFilters, >(): EntityListContextProps; -// @public @deprecated -export function useEntityListProvider< - EntityFilters extends DefaultEntityFilters = DefaultEntityFilters, ->(): EntityListContextProps; - // @public export function useEntityOwnership(): { loading: boolean; diff --git a/plugins/catalog-react/src/hooks/index.ts b/plugins/catalog-react/src/hooks/index.ts index da23d54ad7..9b4955fc91 100644 --- a/plugins/catalog-react/src/hooks/index.ts +++ b/plugins/catalog-react/src/hooks/index.ts @@ -29,7 +29,6 @@ export { useEntityCompoundName } from './useEntityCompoundName'; export { EntityListContext, EntityListProvider, - useEntityListProvider, useEntityList, } from './useEntityListProvider'; export type { diff --git a/plugins/catalog-react/src/hooks/useEntityListProvider.tsx b/plugins/catalog-react/src/hooks/useEntityListProvider.tsx index 72dfb7d1c3..ccac475ae8 100644 --- a/plugins/catalog-react/src/hooks/useEntityListProvider.tsx +++ b/plugins/catalog-react/src/hooks/useEntityListProvider.tsx @@ -249,20 +249,6 @@ export const EntityListProvider = ({ ); }; -/** - * Hook for interacting with the entity list context provided by the {@link EntityListProvider}. - * @public - * @deprecated use {@link useEntityList} instead. - */ -export function useEntityListProvider< - EntityFilters extends DefaultEntityFilters = DefaultEntityFilters, ->(): EntityListContextProps { - const context = useContext(EntityListContext); - if (!context) - throw new Error('useEntityList must be used within EntityListProvider'); - return context; -} - /** * Hook for interacting with the entity list context provided by the {@link EntityListProvider}. * @public From e421d775364ebb9a234c55259b862b786513f2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Fri, 4 Mar 2022 14:09:50 +0100 Subject: [PATCH 26/27] remove deprecations in catalog-backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/many-swans-sort.md | 10 ++++ plugins/catalog-backend/api-report.md | 24 +------- .../src/api/deprecatedResult.ts | 4 +- .../src/api/processingResult.ts | 7 +-- plugins/catalog-backend/src/api/processor.ts | 2 - .../modules/core/StaticLocationProcessor.ts | 59 ------------------- .../catalog-backend/src/modules/core/index.ts | 1 - .../processing/ProcessorOutputCollector.ts | 3 +- plugins/catalog-backend/src/util/index.ts | 1 - .../src/util/runPeriodically.ts | 56 ------------------ 10 files changed, 17 insertions(+), 150 deletions(-) create mode 100644 .changeset/many-swans-sort.md delete mode 100644 plugins/catalog-backend/src/modules/core/StaticLocationProcessor.ts delete mode 100644 plugins/catalog-backend/src/util/runPeriodically.ts diff --git a/.changeset/many-swans-sort.md b/.changeset/many-swans-sort.md new file mode 100644 index 0000000000..fec613cf00 --- /dev/null +++ b/.changeset/many-swans-sort.md @@ -0,0 +1,10 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +**BREAKING**: + +- Removed the previously deprecated `runPeriodically` export. Please use the `@backstage/backend-tasks` package instead, or copy [the actual implementation](https://github.com/backstage/backstage/blob/02875d4d56708c60f86f6b0a5b3da82e24988354/plugins/catalog-backend/src/util/runPeriodically.ts#L29) into your own code if you explicitly do not want coordination of task runs across your worker nodes. +- Removed the previously deprecated `CatalogProcessorLocationResult.optional` field. Please set the corresponding `LocationSpec.presence` field to `'optional'` instead. +- Related to the previous point, the `processingResult.location` function no longer has a second boolean `optional` argument. Please set the corresponding `LocationSpec.presence` field to `'optional'` instead. +- Removed the previously deprecated `StaticLocationProcessor`. It has not been in use for some time; its functionality is covered by `ConfigLocationEntityProvider` instead. diff --git a/plugins/catalog-backend/api-report.md b/plugins/catalog-backend/api-report.md index 0d9f306009..687f1029c5 100644 --- a/plugins/catalog-backend/api-report.md +++ b/plugins/catalog-backend/api-report.md @@ -333,7 +333,6 @@ export type CatalogProcessorErrorResult = { export type CatalogProcessorLocationResult = { type: 'location'; location: LocationSpec; - optional?: boolean; }; // @public @@ -812,7 +811,7 @@ function inputError( // @public @deprecated (undocumented) function location_2( newLocation: LocationSpec, - optional?: boolean, + _optional?: boolean, ): CatalogProcessorResult; // @public (undocumented) @@ -1007,10 +1006,7 @@ export const processingResult: Readonly<{ atLocation: LocationSpec, message: string, ) => CatalogProcessorResult; - readonly location: ( - newLocation: LocationSpec, - optional?: boolean | undefined, - ) => CatalogProcessorResult; + readonly location: (newLocation: LocationSpec) => CatalogProcessorResult; readonly entity: ( atLocation: LocationSpec, newEntity: Entity, @@ -1074,22 +1070,6 @@ export interface RouterOptions { refreshService?: RefreshService; } -// @public @deprecated -export function runPeriodically(fn: () => any, delayMs: number): () => void; - -// @public @deprecated (undocumented) -export class StaticLocationProcessor implements StaticLocationProcessor { - constructor(staticLocations: LocationSpec[]); - // (undocumented) - static fromConfig(config: Config): StaticLocationProcessor; - // (undocumented) - readLocation( - location: LocationSpec, - _optional: boolean, - emit: CatalogProcessorEmit, - ): Promise; -} - // @public (undocumented) export class UrlReaderProcessor implements CatalogProcessor { constructor(options: { reader: UrlReader; logger: Logger_2 }); diff --git a/plugins/catalog-backend/src/api/deprecatedResult.ts b/plugins/catalog-backend/src/api/deprecatedResult.ts index ecacc62c65..e616f3cf7d 100644 --- a/plugins/catalog-backend/src/api/deprecatedResult.ts +++ b/plugins/catalog-backend/src/api/deprecatedResult.ts @@ -68,9 +68,9 @@ export function generalError( */ export function location( newLocation: LocationSpec, - optional?: boolean, + _optional?: boolean, ): CatalogProcessorResult { - return { type: 'location', location: newLocation, optional }; + return { type: 'location', location: newLocation }; } /** diff --git a/plugins/catalog-backend/src/api/processingResult.ts b/plugins/catalog-backend/src/api/processingResult.ts index 5ad908dc8b..2fc2c9eac7 100644 --- a/plugins/catalog-backend/src/api/processingResult.ts +++ b/plugins/catalog-backend/src/api/processingResult.ts @@ -54,11 +54,8 @@ export const processingResult = Object.freeze({ return { type: 'error', location: atLocation, error: new Error(message) }; }, - location( - newLocation: LocationSpec, - optional?: boolean, - ): CatalogProcessorResult { - return { type: 'location', location: newLocation, optional }; + location(newLocation: LocationSpec): CatalogProcessorResult { + return { type: 'location', location: newLocation }; }, entity(atLocation: LocationSpec, newEntity: Entity): CatalogProcessorResult { diff --git a/plugins/catalog-backend/src/api/processor.ts b/plugins/catalog-backend/src/api/processor.ts index 12a008edc7..3f274d13ea 100644 --- a/plugins/catalog-backend/src/api/processor.ts +++ b/plugins/catalog-backend/src/api/processor.ts @@ -147,8 +147,6 @@ export type CatalogProcessorEmit = (generated: CatalogProcessorResult) => void; export type CatalogProcessorLocationResult = { type: 'location'; location: LocationSpec; - /** @deprecated Set `location.presence = 'optional'` instead */ - optional?: boolean; }; /** @public */ diff --git a/plugins/catalog-backend/src/modules/core/StaticLocationProcessor.ts b/plugins/catalog-backend/src/modules/core/StaticLocationProcessor.ts deleted file mode 100644 index e22d011695..0000000000 --- a/plugins/catalog-backend/src/modules/core/StaticLocationProcessor.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2020 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. - */ - -import { Config } from '@backstage/config'; -import { - processingResult, - CatalogProcessorEmit, - LocationSpec, -} from '../../api'; - -/** - * @deprecated no longer in use, replaced by the ConfigLocationEntityProvider. - * @public - */ -export class StaticLocationProcessor implements StaticLocationProcessor { - static fromConfig(config: Config): StaticLocationProcessor { - const locations: LocationSpec[] = []; - - const lConfigs = config.getOptionalConfigArray('catalog.locations') ?? []; - for (const lConfig of lConfigs) { - const type = lConfig.getString('type'); - const target = lConfig.getString('target'); - locations.push({ type, target }); - } - - return new StaticLocationProcessor(locations); - } - - constructor(private readonly staticLocations: LocationSpec[]) {} - - async readLocation( - location: LocationSpec, - _optional: boolean, - emit: CatalogProcessorEmit, - ): Promise { - if (location.type !== 'bootstrap') { - return false; - } - - for (const staticLocation of this.staticLocations) { - emit(processingResult.location(staticLocation)); - } - - return true; - } -} diff --git a/plugins/catalog-backend/src/modules/core/index.ts b/plugins/catalog-backend/src/modules/core/index.ts index 9d582bfb34..364cede069 100644 --- a/plugins/catalog-backend/src/modules/core/index.ts +++ b/plugins/catalog-backend/src/modules/core/index.ts @@ -28,6 +28,5 @@ export type { PlaceholderResolverRead, PlaceholderResolverResolveUrl, } from './PlaceholderProcessor'; -export { StaticLocationProcessor } from './StaticLocationProcessor'; export { UrlReaderProcessor } from './UrlReaderProcessor'; export { parseEntityYaml } from '../util/parse'; diff --git a/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts b/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts index c3cc6e288b..ff12f2f3db 100644 --- a/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts +++ b/plugins/catalog-backend/src/processing/ProcessorOutputCollector.ts @@ -106,9 +106,8 @@ export class ProcessorOutputCollector { this.deferredEntities.push({ entity, locationKey: location }); } else if (i.type === 'location') { - const presence = i.optional ? 'optional' : 'required'; const entity = locationSpecToLocationEntity( - { presence, ...i.location }, + i.location, this.parentEntity, ); const locationKey = getEntityLocationRef(entity); diff --git a/plugins/catalog-backend/src/util/index.ts b/plugins/catalog-backend/src/util/index.ts index 13a9c84b0f..0b5a942e0c 100644 --- a/plugins/catalog-backend/src/util/index.ts +++ b/plugins/catalog-backend/src/util/index.ts @@ -14,5 +14,4 @@ * limitations under the License. */ -export * from './runPeriodically'; export * from './RecursivePartial'; diff --git a/plugins/catalog-backend/src/util/runPeriodically.ts b/plugins/catalog-backend/src/util/runPeriodically.ts deleted file mode 100644 index 361fb33b2f..0000000000 --- a/plugins/catalog-backend/src/util/runPeriodically.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2020 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. - */ - -/** - * Runs a function repeatedly, with a fixed wait between invocations. - * - * Supports async functions, and silently ignores exceptions and rejections. - * - * @param fn - The function to run. May return a Promise. - * @param delayMs - The delay between a completed function invocation and the - * next. - * @returns A function that, when called, stops the invocation loop. - * @deprecated use \@backstage/backend-tasks package instead. - * @public - */ -export function runPeriodically(fn: () => any, delayMs: number): () => void { - let cancel: () => void; - let cancelled = false; - const cancellationPromise = new Promise(resolve => { - cancel = () => { - resolve(); - cancelled = true; - }; - }); - - const startRefresh = async () => { - while (!cancelled) { - try { - await fn(); - } catch { - // ignore intentionally - } - - await Promise.race([ - new Promise(resolve => setTimeout(resolve, delayMs)), - cancellationPromise, - ]); - } - }; - startRefresh(); - - return cancel!; -} From 1360f7d73a2ed1bda6496b6a40a04cbb7e833557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Fri, 4 Mar 2022 14:38:52 +0100 Subject: [PATCH 27/27] remove old ScaffolderTaskOutput link outputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/lazy-points-explain.md | 5 +++ plugins/scaffolder/api-report.md | 16 ++++---- .../src/components/TaskPage/TaskPage.tsx | 8 +--- .../TaskPage/TaskPageLinks.test.tsx | 37 ------------------- .../src/components/TaskPage/TaskPageLinks.tsx | 18 +-------- plugins/scaffolder/src/index.ts | 1 + plugins/scaffolder/src/types.ts | 8 ++-- 7 files changed, 20 insertions(+), 73 deletions(-) create mode 100644 .changeset/lazy-points-explain.md diff --git a/.changeset/lazy-points-explain.md b/.changeset/lazy-points-explain.md new file mode 100644 index 0000000000..ced31c2195 --- /dev/null +++ b/.changeset/lazy-points-explain.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder': minor +--- + +**BREAKING**: Removed `ScaffolderTaskOutput.entityRef` and `ScaffolderTaskOutput.remoteUrl`, which both have been deprecated for over a year. Please use the `links` output instead. diff --git a/plugins/scaffolder/api-report.md b/plugins/scaffolder/api-report.md index b51f18fcc9..9326a61fd5 100644 --- a/plugins/scaffolder/api-report.md +++ b/plugins/scaffolder/api-report.md @@ -314,6 +314,14 @@ export interface ScaffolderGetIntegrationsListResponse { }[]; } +// @public (undocumented) +export type ScaffolderOutputLink = { + title?: string; + icon?: string; + url?: string; + entityRef?: string; +}; + // Warning: (ae-missing-release-tag) "ScaffolderPage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -372,12 +380,8 @@ export type ScaffolderTask = { createdAt: string; }; -// Warning: (ae-missing-release-tag) "ScaffolderTaskOutput" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type ScaffolderTaskOutput = { - entityRef?: string; - remoteUrl?: string; links?: ScaffolderOutputLink[]; } & { [key: string]: unknown; @@ -451,8 +455,4 @@ export const TemplateTypePicker: () => JSX.Element | null; // @public export const useTemplateSecrets: () => ScaffolderUseTemplateSecrets; - -// Warnings were encountered during analysis: -// -// src/types.d.ts:32:5 - (ae-forgotten-export) The symbol "ScaffolderOutputLink" needs to be exported by the entry point index.d.ts ``` diff --git a/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx b/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx index e0445ed641..aab5e8348a 100644 --- a/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx +++ b/plugins/scaffolder/src/components/TaskPage/TaskPage.tsx @@ -217,12 +217,8 @@ export const TaskStatusStepper = memo( }, ); -const hasLinks = ({ - entityRef, - remoteUrl, - links = [], -}: ScaffolderTaskOutput): boolean => - !!(entityRef || remoteUrl || links.length > 0); +const hasLinks = ({ links = [] }: ScaffolderTaskOutput): boolean => + links.length > 0; /** * TaskPageProps for constructing a TaskPage diff --git a/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.test.tsx b/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.test.tsx index 8316b67ff5..2f5d015f8d 100644 --- a/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.test.tsx +++ b/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.test.tsx @@ -26,43 +26,6 @@ describe('TaskPageLinks', () => { jest.resetAllMocks(); }); - it('renders the entityRef link', async () => { - const output = { entityRef: 'Component:default/my-app' }; - const { findByText } = await renderInTestApp( - , - { - mountedRoutes: { - '/catalog/:namespace/:kind/:name/*': entityRouteRef, - }, - }, - ); - - const element = await findByText('Open in catalog'); - - expect(element).toBeInTheDocument(); - expect(element).toHaveAttribute( - 'href', - '/catalog/default/Component/my-app', - ); - }); - - it('renders the remoteUrl link', async () => { - const output = { remoteUrl: 'https://remote.url' }; - const { findByText } = await renderInTestApp( - , - { - mountedRoutes: { - '/catalog/:namespace/:kind/:name/*': entityRouteRef, - }, - }, - ); - - const element = await findByText('Repo'); - - expect(element).toBeInTheDocument(); - expect(element).toHaveAttribute('href', 'https://remote.url'); - }); - it('renders further links', async () => { const output = { links: [ diff --git a/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.tsx b/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.tsx index 5451b4e725..cb77689b6e 100644 --- a/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.tsx +++ b/plugins/scaffolder/src/components/TaskPage/TaskPageLinks.tsx @@ -28,29 +28,13 @@ type TaskPageLinksProps = { }; export const TaskPageLinks = ({ output }: TaskPageLinksProps) => { - const { entityRef: entityRefOutput, remoteUrl } = output; - let { links = [] } = output; + const { links = [] } = output; const app = useApp(); const entityRoute = useRouteRef(entityRouteRef); const iconResolver = (key?: string): IconComponent => key ? app.getSystemIcon(key) ?? LanguageIcon : LanguageIcon; - if (remoteUrl) { - links = [{ url: remoteUrl, title: 'Repo' }, ...links]; - } - - if (entityRefOutput) { - links = [ - { - entityRef: entityRefOutput, - title: 'Open in catalog', - icon: 'catalog', - }, - ...links, - ]; - } - return ( {links diff --git a/plugins/scaffolder/src/index.ts b/plugins/scaffolder/src/index.ts index f33cf289f4..34b9155d66 100644 --- a/plugins/scaffolder/src/index.ts +++ b/plugins/scaffolder/src/index.ts @@ -28,6 +28,7 @@ export type { ScaffolderApi, ScaffolderGetIntegrationsListOptions, ScaffolderGetIntegrationsListResponse, + ScaffolderOutputLink, ScaffolderScaffoldOptions, ScaffolderScaffoldResponse, ScaffolderStreamLogsOptions, diff --git a/plugins/scaffolder/src/types.ts b/plugins/scaffolder/src/types.ts index 0ffbd601a8..069c28d85c 100644 --- a/plugins/scaffolder/src/types.ts +++ b/plugins/scaffolder/src/types.ts @@ -43,18 +43,16 @@ export type ListActionsResponse = Array<{ }; }>; -type ScaffolderOutputLink = { +/** @public */ +export type ScaffolderOutputLink = { title?: string; icon?: string; url?: string; entityRef?: string; }; +/** @public */ export type ScaffolderTaskOutput = { - /** @deprecated use the `links` property to link out to relevant resources */ - entityRef?: string; - /** @deprecated use the `links` property to link out to relevant resources */ - remoteUrl?: string; links?: ScaffolderOutputLink[]; } & { [key: string]: unknown;