From 8183a407b07e79d7dd4595a14d4d8f89bae5bd63 Mon Sep 17 00:00:00 2001 From: Balasundaram Date: Mon, 29 Nov 2021 12:15:02 -0500 Subject: [PATCH 01/41] Adding changes for creating action for gitlab MR request during component registration similar to github Signed-off-by: Balasundaram --- .../actions/builtin/createBuiltinActions.ts | 4 + .../builtin/publish/gitlabMergeRequest.ts | 174 ++++++++++++++++++ .../actions/builtin/publish/index.ts | 1 + 3 files changed, 179 insertions(+) create mode 100644 plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts index d38dfe3cdc..2d916af77e 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts @@ -36,6 +36,7 @@ import { createPublishGithubAction, createPublishGithubPullRequestAction, createPublishGitlabAction, + createPublishGitlabMergeRequestAction, } from './publish'; import { createGithubActionsDispatchAction, @@ -77,6 +78,9 @@ export const createBuiltinActions = (options: { integrations, config, }), + createPublishGitlabMergeRequestAction({ + integrations, + }), createPublishBitbucketAction({ integrations, config, diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts new file mode 100644 index 0000000000..6ff10deb96 --- /dev/null +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts @@ -0,0 +1,174 @@ +/* + * Copyright 2021 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 { createTemplateAction } from '../../createTemplateAction'; +import { readFile } from 'fs-extra'; +import { Gitlab } from '@gitbeaker/node'; +import path from 'path'; +import globby from 'globby'; +import { CommitAction } from '@gitbeaker/core/dist/types/services/Commits'; +import { CreateMergeRequestOptions } from '@gitbeaker/core/dist/types/services/MergeRequests'; +import { ScmIntegrationRegistry } from '@backstage/integration'; +import { InputError } from '@backstage/errors'; +import { parseRepoUrl } from './util'; + +export type GitlabMergeRequestActionInput = { + projectid: string; + repoUrl: string; + title: string; + description: string; + destinationBranch: string; + targetPath: string; + }; + +export const createPublishGitlabMergeRequestAction = (options: { + integrations: ScmIntegrationRegistry; + }) => { + const { integrations } = options; + + return createTemplateAction({ + id: 'publish:gitlab-merge-request', + schema: { + input: { + required: ['projectid', 'repoUrl', 'targetPath'], + type: 'object', + properties: { + repoUrl: { + type: 'string', + title: 'Repository Location', + description: `Accepts the format 'gitlab.com/group_name/project_name' where 'project_name' is the repository name and 'group_name' is a group or username`, + }, + projectid: { + type: 'string', + title: 'projectid', + description: 'Project ID of the Gitlab Project', + }, + title: { + type: 'string', + title: 'Merge Request Name', + description: 'The name for the merge request', + }, + description: { + type: 'string', + title: 'Merge Request Description', + description: 'The description of the merge request', + }, + destinationBranch: { + type: 'string', + title: 'Destination Branch name', + description: 'The description of the merge request', + }, + targetPath: { + type: 'string', + title: 'Repository Subdirectory', + description: 'Subdirectory of repository to apply changes to', + } + }, + }, + output: { + type: 'object', + properties: { + projectid : { + title: 'Gitlab Project id', + type: 'string', + }, + mergeRequestURL: { + title: 'MergeRequest(MR) URL', + type: 'string', + description: 'Link to the merge request in GitLab', + }, + }, + }, + }, + async handler(ctx) { + const repoUrl = ctx.input.repoUrl; + const { host } = parseRepoUrl(repoUrl, integrations); + const integrationConfig = integrations.gitlab.byHost(host); + + let actions: CommitAction[] = []; + const formatedTimestamp = ()=> { + const d = new Date() + const date = d.toISOString().split('T')[0]; + const time = d.toTimeString().split(' ')[0].replace(/:/g, "_"); + return `${date}_${time}` + } + const destinationBranch = ctx.input.destinationBranch? ctx.input.destinationBranch + formatedTimestamp(): `backstage_${formatedTimestamp()}`; + + if (!integrationConfig) { + throw new InputError( + `No matching integration configuration for host ${host}, please check your integrations config`, + ); + } + + if (!integrationConfig.config.token) { + throw new InputError(`No token available for host ${host}`); + } + + const api = new Gitlab({ + host: integrationConfig.config.baseUrl, + token: integrationConfig.config.token, + }); + + const fileRoot = ctx.workspacePath; + const localFilePaths = await globby([`${ctx.input.targetPath}'/**'`], { + cwd: fileRoot, + gitignore: true, + dot: true, + }); + + const fileContents = await Promise.all( + localFilePaths.map(p => readFile(path.resolve(fileRoot, p))), + ); + + const repoFilePaths = localFilePaths.map(repoFilePath => { + return repoFilePath; + }); + + for(let i=0; i { + return projectJSON?.default_branch; + }); + + try { + await api.Branches.create(ctx.input.projectid, destinationBranch, defaultBranch).then((branchResponse) => { + return branchResponse; + }); + } catch(e) { + throw new InputError(`The branch creation failed ` + e); + } + + try { + await api.Commits.create(ctx.input.projectid, destinationBranch, ctx.input.title, actions); + } catch(e) { + throw new InputError(`Committing the changes to ` + destinationBranch + ` failed ` + e); + } + + try { + let mergeRequestUrl: any = await api.MergeRequests.create(ctx.input.projectid, destinationBranch, defaultBranch, ctx.input.title, { description: ctx.input.description }).then((mergeRequest) => { + return mergeRequest.web_url + }); + ctx.output('projectid', ctx.input.projectid); + ctx.output('mergeRequestUrl', mergeRequestUrl); + } + catch(e) { + throw new InputError(`Merge request creation failed` + e); + } + }, + }); +}; \ No newline at end of file diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts index a292438d3a..75af6e190f 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts @@ -20,3 +20,4 @@ export { createPublishFileAction } from './file'; export { createPublishGithubAction } from './github'; export { createPublishGithubPullRequestAction } from './githubPullRequest'; export { createPublishGitlabAction } from './gitlab'; +export { createPublishGitlabMergeRequestAction } from './gitlabMergeRequest'; \ No newline at end of file From 86ac8d6cdb6fe45b9f2f434bedcc96863288b014 Mon Sep 17 00:00:00 2001 From: Balasundaram Date: Mon, 29 Nov 2021 13:43:47 -0500 Subject: [PATCH 02/41] Adding prettier changes Signed-off-by: Balasundaram --- .../builtin/publish/gitlabMergeRequest.ts | 289 ++++++++++-------- 1 file changed, 156 insertions(+), 133 deletions(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts index 6ff10deb96..19aeabefdd 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts @@ -19,156 +19,179 @@ import { Gitlab } from '@gitbeaker/node'; import path from 'path'; import globby from 'globby'; import { CommitAction } from '@gitbeaker/core/dist/types/services/Commits'; -import { CreateMergeRequestOptions } from '@gitbeaker/core/dist/types/services/MergeRequests'; +import { CreateMergeRequestOptions } from '@gitbeaker/core/dist/types/services/MergeRequests'; import { ScmIntegrationRegistry } from '@backstage/integration'; import { InputError } from '@backstage/errors'; import { parseRepoUrl } from './util'; export type GitlabMergeRequestActionInput = { - projectid: string; - repoUrl: string; - title: string; - description: string; - destinationBranch: string; - targetPath: string; - }; + projectid: string; + repoUrl: string; + title: string; + description: string; + destinationBranch: string; + targetPath: string; +}; export const createPublishGitlabMergeRequestAction = (options: { - integrations: ScmIntegrationRegistry; - }) => { - const { integrations } = options; + integrations: ScmIntegrationRegistry; +}) => { + const { integrations } = options; - return createTemplateAction({ - id: 'publish:gitlab-merge-request', - schema: { - input: { - required: ['projectid', 'repoUrl', 'targetPath'], - type: 'object', - properties: { - repoUrl: { - type: 'string', - title: 'Repository Location', - description: `Accepts the format 'gitlab.com/group_name/project_name' where 'project_name' is the repository name and 'group_name' is a group or username`, - }, - projectid: { - type: 'string', - title: 'projectid', - description: 'Project ID of the Gitlab Project', - }, - title: { - type: 'string', - title: 'Merge Request Name', - description: 'The name for the merge request', - }, - description: { - type: 'string', - title: 'Merge Request Description', - description: 'The description of the merge request', - }, - destinationBranch: { - type: 'string', - title: 'Destination Branch name', - description: 'The description of the merge request', - }, - targetPath: { - type: 'string', - title: 'Repository Subdirectory', - description: 'Subdirectory of repository to apply changes to', - } - }, - }, - output: { - type: 'object', - properties: { - projectid : { - title: 'Gitlab Project id', - type: 'string', - }, - mergeRequestURL: { - title: 'MergeRequest(MR) URL', - type: 'string', - description: 'Link to the merge request in GitLab', - }, - }, - }, - }, - async handler(ctx) { - const repoUrl = ctx.input.repoUrl; - const { host } = parseRepoUrl(repoUrl, integrations); - const integrationConfig = integrations.gitlab.byHost(host); + return createTemplateAction({ + id: 'publish:gitlab-merge-request', + schema: { + input: { + required: ['projectid', 'repoUrl', 'targetPath'], + type: 'object', + properties: { + repoUrl: { + type: 'string', + title: 'Repository Location', + description: `Accepts the format 'gitlab.com/group_name/project_name' where 'project_name' is the repository name and 'group_name' is a group or username`, + }, + projectid: { + type: 'string', + title: 'projectid', + description: 'Project ID of the Gitlab Project', + }, + title: { + type: 'string', + title: 'Merge Request Name', + description: 'The name for the merge request', + }, + description: { + type: 'string', + title: 'Merge Request Description', + description: 'The description of the merge request', + }, + destinationBranch: { + type: 'string', + title: 'Destination Branch name', + description: 'The description of the merge request', + }, + targetPath: { + type: 'string', + title: 'Repository Subdirectory', + description: 'Subdirectory of repository to apply changes to', + }, + }, + }, + output: { + type: 'object', + properties: { + projectid: { + title: 'Gitlab Project id', + type: 'string', + }, + mergeRequestURL: { + title: 'MergeRequest(MR) URL', + type: 'string', + description: 'Link to the merge request in GitLab', + }, + }, + }, + }, + async handler(ctx) { + const repoUrl = ctx.input.repoUrl; + const { host } = parseRepoUrl(repoUrl, integrations); + const integrationConfig = integrations.gitlab.byHost(host); - let actions: CommitAction[] = []; - const formatedTimestamp = ()=> { - const d = new Date() - const date = d.toISOString().split('T')[0]; - const time = d.toTimeString().split(' ')[0].replace(/:/g, "_"); - return `${date}_${time}` - } - const destinationBranch = ctx.input.destinationBranch? ctx.input.destinationBranch + formatedTimestamp(): `backstage_${formatedTimestamp()}`; + const actions: CommitAction[] = []; + const formatedTimestamp = () => { + const d = new Date(); + const date = d.toISOString().split('T')[0]; + const time = d.toTimeString().split(' ')[0].replace(/:/g, '_'); + return `${date}_${time}`; + }; + const destinationBranch = ctx.input.destinationBranch + ? ctx.input.destinationBranch + formatedTimestamp() + : `backstage_${formatedTimestamp()}`; - if (!integrationConfig) { - throw new InputError( - `No matching integration configuration for host ${host}, please check your integrations config`, - ); - } + if (!integrationConfig) { + throw new InputError( + `No matching integration configuration for host ${host}, please check your integrations config`, + ); + } - if (!integrationConfig.config.token) { - throw new InputError(`No token available for host ${host}`); - } + if (!integrationConfig.config.token) { + throw new InputError(`No token available for host ${host}`); + } - const api = new Gitlab({ - host: integrationConfig.config.baseUrl, - token: integrationConfig.config.token, - }); + const api = new Gitlab({ + host: integrationConfig.config.baseUrl, + token: integrationConfig.config.token, + }); - const fileRoot = ctx.workspacePath; - const localFilePaths = await globby([`${ctx.input.targetPath}'/**'`], { - cwd: fileRoot, - gitignore: true, - dot: true, - }); + const fileRoot = ctx.workspacePath; + const localFilePaths = await globby([`${ctx.input.targetPath}'/**'`], { + cwd: fileRoot, + gitignore: true, + dot: true, + }); - const fileContents = await Promise.all( - localFilePaths.map(p => readFile(path.resolve(fileRoot, p))), - ); + const fileContents = await Promise.all( + localFilePaths.map(p => readFile(path.resolve(fileRoot, p))), + ); - const repoFilePaths = localFilePaths.map(repoFilePath => { - return repoFilePath; - }); + const repoFilePaths = localFilePaths.map(repoFilePath => { + return repoFilePath; + }); - for(let i=0; i { + return projectJSON?.default_branch; + }); - const defaultBranch: any = await api.Projects.show(ctx.input.projectid).then((projectJSON) => { - return projectJSON?.default_branch; - }); + try { + await api.Branches.create( + ctx.input.projectid, + destinationBranch, + defaultBranch, + ).then(branchResponse => { + return branchResponse; + }); + } catch (e) { + throw new InputError(`The branch creation failed ${e}`); + } - try { - await api.Branches.create(ctx.input.projectid, destinationBranch, defaultBranch).then((branchResponse) => { - return branchResponse; - }); - } catch(e) { - throw new InputError(`The branch creation failed ` + e); - } + try { + await api.Commits.create( + ctx.input.projectid, + destinationBranch, + ctx.input.title, + actions, + ); + } catch (e) { + throw new InputError( + `Committing the changes to ${destinationBranch} failed ${e}`, + ); + } - try { - await api.Commits.create(ctx.input.projectid, destinationBranch, ctx.input.title, actions); - } catch(e) { - throw new InputError(`Committing the changes to ` + destinationBranch + ` failed ` + e); - } - - try { - let mergeRequestUrl: any = await api.MergeRequests.create(ctx.input.projectid, destinationBranch, defaultBranch, ctx.input.title, { description: ctx.input.description }).then((mergeRequest) => { - return mergeRequest.web_url - }); - ctx.output('projectid', ctx.input.projectid); - ctx.output('mergeRequestUrl', mergeRequestUrl); - } - catch(e) { - throw new InputError(`Merge request creation failed` + e); - } - }, - }); -}; \ No newline at end of file + try { + const mergeRequestUrl: any = await api.MergeRequests.create( + ctx.input.projectid, + destinationBranch, + defaultBranch, + ctx.input.title, + { description: ctx.input.description }, + ).then(mergeRequest => { + return mergeRequest.web_url; + }); + ctx.output('projectid', ctx.input.projectid); + ctx.output('mergeRequestUrl', mergeRequestUrl); + } catch (e) { + throw new InputError(`Merge request creation failed${e}`); + } + }, + }); +}; From d9d2ff253d40098c8230d0509e67185a6a5f1f0e Mon Sep 17 00:00:00 2001 From: Balasundaram Date: Tue, 30 Nov 2021 06:44:27 -0500 Subject: [PATCH 03/41] Adding prettier for index.ts Signed-off-by: Balasundaram --- .../src/scaffolder/actions/builtin/publish/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts index 75af6e190f..c42b04e55e 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts @@ -20,4 +20,4 @@ export { createPublishFileAction } from './file'; export { createPublishGithubAction } from './github'; export { createPublishGithubPullRequestAction } from './githubPullRequest'; export { createPublishGitlabAction } from './gitlab'; -export { createPublishGitlabMergeRequestAction } from './gitlabMergeRequest'; \ No newline at end of file +export { createPublishGitlabMergeRequestAction } from './gitlabMergeRequest'; From 89599a43c628b6b7004fe7aa8301b40f2597b744 Mon Sep 17 00:00:00 2001 From: Balasundaram Date: Wed, 1 Dec 2021 12:50:16 -0500 Subject: [PATCH 04/41] Adding changes for PR review comments Signed-off-by: Balasundaram --- .../builtin/publish/gitlabMergeRequest.ts | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts index 19aeabefdd..0928ff3b6d 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts @@ -16,20 +16,19 @@ import { createTemplateAction } from '../../createTemplateAction'; import { readFile } from 'fs-extra'; import { Gitlab } from '@gitbeaker/node'; -import path from 'path'; import globby from 'globby'; import { CommitAction } from '@gitbeaker/core/dist/types/services/Commits'; -import { CreateMergeRequestOptions } from '@gitbeaker/core/dist/types/services/MergeRequests'; import { ScmIntegrationRegistry } from '@backstage/integration'; import { InputError } from '@backstage/errors'; import { parseRepoUrl } from './util'; +import { resolveSafeChildPath } from '@backstage/backend-common'; export type GitlabMergeRequestActionInput = { projectid: string; repoUrl: string; title: string; description: string; - destinationBranch: string; + branchName: string; targetPath: string; }; @@ -39,10 +38,10 @@ export const createPublishGitlabMergeRequestAction = (options: { const { integrations } = options; return createTemplateAction({ - id: 'publish:gitlab-merge-request', + id: 'publish:gitlab:merge-request', schema: { input: { - required: ['projectid', 'repoUrl', 'targetPath'], + required: ['projectid', 'repoUrl', 'targetPath', 'branchName'], type: 'object', properties: { repoUrl: { @@ -65,7 +64,7 @@ export const createPublishGitlabMergeRequestAction = (options: { title: 'Merge Request Description', description: 'The description of the merge request', }, - destinationBranch: { + branchName: { type: 'string', title: 'Destination Branch name', description: 'The description of the merge request', @@ -98,15 +97,8 @@ export const createPublishGitlabMergeRequestAction = (options: { const integrationConfig = integrations.gitlab.byHost(host); const actions: CommitAction[] = []; - const formatedTimestamp = () => { - const d = new Date(); - const date = d.toISOString().split('T')[0]; - const time = d.toTimeString().split(' ')[0].replace(/:/g, '_'); - return `${date}_${time}`; - }; - const destinationBranch = ctx.input.destinationBranch - ? ctx.input.destinationBranch + formatedTimestamp() - : `backstage_${formatedTimestamp()}`; + + const destinationBranch = ctx.input.branchName; if (!integrationConfig) { throw new InputError( @@ -124,14 +116,14 @@ export const createPublishGitlabMergeRequestAction = (options: { }); const fileRoot = ctx.workspacePath; - const localFilePaths = await globby([`${ctx.input.targetPath}'/**'`], { + const localFilePaths = await globby([`${ctx.input.targetPath}/**`], { cwd: fileRoot, gitignore: true, dot: true, }); const fileContents = await Promise.all( - localFilePaths.map(p => readFile(path.resolve(fileRoot, p))), + localFilePaths.map(p => readFile(resolveSafeChildPath(fileRoot, p))), ); const repoFilePaths = localFilePaths.map(repoFilePath => { @@ -146,11 +138,9 @@ export const createPublishGitlabMergeRequestAction = (options: { }); } - const defaultBranch: any = await api.Projects.show( + const { default_branch: defaultBranch }: any = await api.Projects.show( ctx.input.projectid, - ).then(projectJSON => { - return projectJSON?.default_branch; - }); + ); try { await api.Branches.create( From a955e16875ca60e4a8ffe954704528fb64909d7a Mon Sep 17 00:00:00 2001 From: Balasundaram Date: Thu, 2 Dec 2021 10:49:14 -0500 Subject: [PATCH 05/41] Adding changes for PR review comments II Signed-off-by: Balasundaram --- .../actions/builtin/publish/gitlabMergeRequest.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts index 0928ff3b6d..8238d040b2 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts @@ -138,15 +138,15 @@ export const createPublishGitlabMergeRequestAction = (options: { }); } - const { default_branch: defaultBranch }: any = await api.Projects.show( - ctx.input.projectid, - ); + const projects = await api.Projects.show(ctx.input.projectid); + + const { default_branch: defaultBranch } = projects; try { await api.Branches.create( ctx.input.projectid, destinationBranch, - defaultBranch, + String(defaultBranch), ).then(branchResponse => { return branchResponse; }); @@ -171,7 +171,7 @@ export const createPublishGitlabMergeRequestAction = (options: { const mergeRequestUrl: any = await api.MergeRequests.create( ctx.input.projectid, destinationBranch, - defaultBranch, + String(defaultBranch), ctx.input.title, { description: ctx.input.description }, ).then(mergeRequest => { From 8ee5b6f3dd7da14a8f0495a31ab7fe38cd4bad46 Mon Sep 17 00:00:00 2001 From: Balasundaram Date: Wed, 8 Dec 2021 16:34:09 -0500 Subject: [PATCH 06/41] Adding changes for PR review comments III Signed-off-by: Balasundaram --- plugins/scaffolder-backend/package.json | 4 ++-- .../builtin/publish/gitlabMergeRequest.ts | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json index fe5d61d4d3..21f554779f 100644 --- a/plugins/scaffolder-backend/package.json +++ b/plugins/scaffolder-backend/package.json @@ -40,8 +40,8 @@ "@backstage/plugin-scaffolder-common": "^0.1.1", "@backstage/plugin-scaffolder-backend-module-cookiecutter": "^0.1.3", "@backstage/types": "^0.1.1", - "@gitbeaker/core": "^30.2.0", - "@gitbeaker/node": "^30.2.0", + "@gitbeaker/core": "^35.1.0", + "@gitbeaker/node": "^35.1.0", "@octokit/rest": "^18.5.3", "@octokit/webhooks": "^9.14.1", "@types/express": "^4.17.6", diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts index 8238d040b2..b333b5234d 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts @@ -17,7 +17,8 @@ import { createTemplateAction } from '../../createTemplateAction'; import { readFile } from 'fs-extra'; import { Gitlab } from '@gitbeaker/node'; import globby from 'globby'; -import { CommitAction } from '@gitbeaker/core/dist/types/services/Commits'; +import { Types } from '@gitbeaker/core'; + import { ScmIntegrationRegistry } from '@backstage/integration'; import { InputError } from '@backstage/errors'; import { parseRepoUrl } from './util'; @@ -96,7 +97,11 @@ export const createPublishGitlabMergeRequestAction = (options: { const { host } = parseRepoUrl(repoUrl, integrations); const integrationConfig = integrations.gitlab.byHost(host); - const actions: CommitAction[] = []; + /* const a : Types.CommitAction = { + action: 'create', + filePath: '' + };*/ + const actions: Types.CommitAction[] = []; const destinationBranch = ctx.input.branchName; @@ -147,9 +152,7 @@ export const createPublishGitlabMergeRequestAction = (options: { ctx.input.projectid, destinationBranch, String(defaultBranch), - ).then(branchResponse => { - return branchResponse; - }); + ); } catch (e) { throw new InputError(`The branch creation failed ${e}`); } @@ -168,13 +171,13 @@ export const createPublishGitlabMergeRequestAction = (options: { } try { - const mergeRequestUrl: any = await api.MergeRequests.create( + const mergeRequestUrl = await api.MergeRequests.create( ctx.input.projectid, destinationBranch, String(defaultBranch), ctx.input.title, { description: ctx.input.description }, - ).then(mergeRequest => { + ).then((mergeRequest: { web_url: string }) => { return mergeRequest.web_url; }); ctx.output('projectid', ctx.input.projectid); From 90f8f33355fd3a15fe68fcc08eb4d3c409dc1db8 Mon Sep 17 00:00:00 2001 From: Balasundaram Date: Thu, 9 Dec 2021 12:57:18 -0500 Subject: [PATCH 07/41] Adding changes for PR review comments to add description for projectname Signed-off-by: Balasundaram --- .../scaffolder/actions/builtin/publish/gitlabMergeRequest.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts index b333b5234d..b64ec1a83d 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts @@ -53,7 +53,7 @@ export const createPublishGitlabMergeRequestAction = (options: { projectid: { type: 'string', title: 'projectid', - description: 'Project ID of the Gitlab Project', + description: 'Project ID/Name(slug) of the Gitlab Project', }, title: { type: 'string', @@ -81,7 +81,7 @@ export const createPublishGitlabMergeRequestAction = (options: { type: 'object', properties: { projectid: { - title: 'Gitlab Project id', + title: 'Gitlab Project id/Name(slug)', type: 'string', }, mergeRequestURL: { From ed52f74ab3c2dceb27f07bd0ba509fdcf732a673 Mon Sep 17 00:00:00 2001 From: Balasundaram Date: Thu, 9 Dec 2021 13:06:04 -0500 Subject: [PATCH 08/41] Adding changeset for the #8277 Signed-off-by: Balasundaram --- .changeset/nervous-hounds-attend.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/nervous-hounds-attend.md diff --git a/.changeset/nervous-hounds-attend.md b/.changeset/nervous-hounds-attend.md new file mode 100644 index 0000000000..a9eed8422d --- /dev/null +++ b/.changeset/nervous-hounds-attend.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': minor +--- + +Adding changes to create Gitlab Merge Request using custom action From 646e5d01d8baff61429be714451528bc0d7fa81d Mon Sep 17 00:00:00 2001 From: Balasundaram Date: Thu, 9 Dec 2021 13:13:04 -0500 Subject: [PATCH 09/41] Changing minor to patch changeset for the #8277 Signed-off-by: Balasundaram --- .changeset/nervous-hounds-attend.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/nervous-hounds-attend.md b/.changeset/nervous-hounds-attend.md index a9eed8422d..15ca4aa085 100644 --- a/.changeset/nervous-hounds-attend.md +++ b/.changeset/nervous-hounds-attend.md @@ -1,5 +1,5 @@ --- -'@backstage/plugin-scaffolder-backend': minor +'@backstage/plugin-scaffolder-backend': patch --- Adding changes to create Gitlab Merge Request using custom action From ccf48de9ba82aa62d23b4e3f4aa0a4dcc66b660a Mon Sep 17 00:00:00 2001 From: Balasundaram Date: Thu, 9 Dec 2021 13:16:48 -0500 Subject: [PATCH 10/41] Adding changes to remove comments Signed-off-by: Balasundaram --- .../scaffolder/actions/builtin/publish/gitlabMergeRequest.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts index b64ec1a83d..2ac369249b 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/gitlabMergeRequest.ts @@ -97,10 +97,6 @@ export const createPublishGitlabMergeRequestAction = (options: { const { host } = parseRepoUrl(repoUrl, integrations); const integrationConfig = integrations.gitlab.byHost(host); - /* const a : Types.CommitAction = { - action: 'create', - filePath: '' - };*/ const actions: Types.CommitAction[] = []; const destinationBranch = ctx.input.branchName; From a516412bb3777ea59af09a995cdb6fb4df0b8e33 Mon Sep 17 00:00:00 2001 From: Balasundaram Date: Thu, 9 Dec 2021 14:50:19 -0500 Subject: [PATCH 11/41] Adding public api report Signed-off-by: Balasundaram --- plugins/scaffolder-backend/api-report.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index 6ed4625f66..bf03443419 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -179,6 +179,13 @@ export function createPublishGitlabAction(options: { config: Config; }): TemplateAction; +// Warning: (ae-missing-release-tag) "createPublishGitlabMergeRequestAction" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const createPublishGitlabMergeRequestAction: (options: { + integrations: ScmIntegrationRegistry; +}) => TemplateAction; + // Warning: (ae-missing-release-tag) "createRouter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) From eec0750d8d85c2a1eaefc36c10763b5668d80561 Mon Sep 17 00:00:00 2001 From: Phil Gore Date: Fri, 10 Dec 2021 14:42:42 -0600 Subject: [PATCH 12/41] making cookiecutter an optional action based on passing in containerRunner Signed-off-by: Phil Gore --- .changeset/mighty-llamas-hope.md | 5 +++++ .../actions/builtin/createBuiltinActions.ts | 21 ++++++++++++------- .../scaffolder-backend/src/service/router.ts | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 .changeset/mighty-llamas-hope.md diff --git a/.changeset/mighty-llamas-hope.md b/.changeset/mighty-llamas-hope.md new file mode 100644 index 0000000000..7ea87e50d0 --- /dev/null +++ b/.changeset/mighty-llamas-hope.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Makes cookiecutter a default, but optional action based on if a containerRunner argument is passed in to createRouter or createBuiltinActions diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts index d38dfe3cdc..5ecdc1d595 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts @@ -46,22 +46,17 @@ export const createBuiltinActions = (options: { reader: UrlReader; integrations: ScmIntegrations; catalogClient: CatalogApi; - containerRunner: ContainerRunner; + containerRunner?: ContainerRunner; config: Config; }) => { const { reader, integrations, containerRunner, catalogClient, config } = options; - return [ + const actions = [ createFetchPlainAction({ reader, integrations, }), - createFetchCookiecutterAction({ - reader, - integrations, - containerRunner, - }), createFetchTemplateAction({ integrations, reader, @@ -97,4 +92,16 @@ export const createBuiltinActions = (options: { integrations, }), ]; + + if (containerRunner) { + actions.push( + createFetchCookiecutterAction({ + reader, + integrations, + containerRunner, + }), + ); + } + + return actions; }; diff --git a/plugins/scaffolder-backend/src/service/router.ts b/plugins/scaffolder-backend/src/service/router.ts index b8f2968287..9d26857ab9 100644 --- a/plugins/scaffolder-backend/src/service/router.ts +++ b/plugins/scaffolder-backend/src/service/router.ts @@ -55,7 +55,7 @@ export interface RouterOptions { catalogClient: CatalogApi; actions?: TemplateAction[]; taskWorkers?: number; - containerRunner: ContainerRunner; + containerRunner?: ContainerRunner; taskBroker?: TaskBroker; } From 2e4bc16c4a640f5ab9e321eb11fbb2e02c04d74b Mon Sep 17 00:00:00 2001 From: Phil Gore Date: Fri, 10 Dec 2021 14:55:02 -0600 Subject: [PATCH 13/41] adding scaffolder api report Signed-off-by: Phil Gore --- plugins/scaffolder-backend/api-report.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index 6ed4625f66..767b431352 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -68,7 +68,7 @@ export const createBuiltinActions: (options: { reader: UrlReader; integrations: ScmIntegrations; catalogClient: CatalogApi; - containerRunner: ContainerRunner; + containerRunner?: ContainerRunner; config: Config; }) => TemplateAction[]; @@ -289,7 +289,7 @@ export interface RouterOptions { // (undocumented) config: Config; // (undocumented) - containerRunner: ContainerRunner; + containerRunner?: ContainerRunner; // (undocumented) database: PluginDatabaseManager; // (undocumented) From da156f2831888a0a474f99899b11d7792b54b05d Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Sat, 11 Dec 2021 12:46:17 +0100 Subject: [PATCH 14/41] let's support also entities without spec.type Signed-off-by: Jan Vilimek --- .../src/components/Cards/OwnershipCard/OwnershipCard.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx index fe23191779..091e8037ca 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx @@ -162,17 +162,15 @@ export const OwnershipCard = ({ const counts = ownedEntitiesList.reduce( (acc: EntityTypeProps[], ownedEntity) => { - if (typeof ownedEntity.spec?.type !== 'string') return acc; - const match = acc.find( - x => x.kind === ownedEntity.kind && x.type === ownedEntity.spec?.type, + x => x.kind === ownedEntity.kind && x.type === (ownedEntity.spec?.type ?? ownedEntity.kind), ); if (match) { match.count += 1; } else { acc.push({ kind: ownedEntity.kind, - type: ownedEntity.spec?.type, + type: ownedEntity.spec?.type?.toString() ?? ownedEntity.kind, count: 1, }); } From 26b04d2341739d65dc8145e8e0b3b08617757867 Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Sat, 11 Dec 2021 12:48:14 +0100 Subject: [PATCH 15/41] New arg entityFilterKind for ownershipcard Signed-off-by: Jan Vilimek --- .../org/src/components/Cards/OwnershipCard/OwnershipCard.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx index 091e8037ca..56e87a26f6 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx @@ -128,10 +128,12 @@ const getQueryParams = ( export const OwnershipCard = ({ variant, + entityFilterKind }: { /** @deprecated The entity is now grabbed from context instead */ entity?: Entity; variant?: InfoCardVariants; + entityFilterKind?: string[]; }) => { const { entity } = useEntity(); const catalogApi = useApi(catalogApiRef); @@ -142,7 +144,7 @@ export const OwnershipCard = ({ error, value: componentsWithCounters, } = useAsync(async () => { - const kinds = ['Component', 'API']; + const kinds = entityFilterKind ?? ['Component', 'API']; const entitiesList = await catalogApi.getEntities({ filter: { kind: kinds, From 455da34c98ce6fc60e414ce4aec80ce1a3ac9cf6 Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Sat, 11 Dec 2021 12:49:39 +0100 Subject: [PATCH 16/41] jest tests for ownershipCard improved Signed-off-by: Jan Vilimek --- .../OwnershipCard/OwnershipCard.test.tsx | 152 ++++++++++++++++++ 1 file changed, 152 insertions(+) diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx index 8d6fc1a002..e5bf36ba8e 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx @@ -108,6 +108,22 @@ describe('OwnershipCard', () => { }, ], }, + { + kind: 'system', + metadata: { + name: 'my-systen', + }, + relations: [ + { + type: 'ownedBy', + target: { + name: 'my-team', + namespace: 'default', + kind: 'Group', + }, + }, + ], + }, ] as any; it('displays entity counts', async () => { @@ -144,6 +160,7 @@ describe('OwnershipCard', () => { expect( queryByText(getByText('LIBRARY').parentElement!, '1'), ).toBeInTheDocument(); + expect(getByText('SYSTEM')).not.toBeInTheDocument(); }); it('links to the catalog with the group filter', async () => { @@ -222,3 +239,138 @@ describe('OwnershipCard', () => { ); }); }); + +describe('OwnershipCardWithCustomFilterDefinition', () => { + const groupEntity: GroupEntity = { + apiVersion: 'backstage.io/v1alpha1', + kind: 'Group', + metadata: { + name: 'my-team', + }, + spec: { + type: 'team', + children: [], + }, + relations: [ + { + type: 'memberOf', + target: { + kind: 'group', + name: 'ExampleGroup', + namespace: 'default', + }, + }, + ], + }; + + const items = [ + { + kind: 'API', + metadata: { + name: 'my-api', + }, + spec: { + type: 'openapi', + }, + relations: [ + { + type: 'ownedBy', + target: { + name: 'my-team', + namespace: 'default', + kind: 'Group', + }, + }, + ], + }, + { + kind: 'Component', + metadata: { + name: 'my-service', + }, + spec: { + type: 'service', + }, + relations: [ + { + type: 'ownedBy', + target: { + name: 'my-team', + namespace: 'default', + kind: 'Group', + }, + }, + ], + }, + { + kind: 'Component', + metadata: { + name: 'my-library', + namespace: 'other-namespace', + }, + spec: { + type: 'library', + }, + relations: [ + { + type: 'ownedBy', + target: { + name: 'my-team', + namespace: 'default', + kind: 'Group', + }, + }, + ], + }, + { + kind: 'system', + metadata: { + name: 'my-systen', + }, + relations: [ + { + type: 'ownedBy', + target: { + name: 'my-team', + namespace: 'default', + kind: 'Group', + }, + }, + ], + }, + ] as any; + + it('displays entity counts', async () => { + const catalogApi: jest.Mocked = { + getEntities: jest.fn(), + } as any; + + catalogApi.getEntities.mockResolvedValue({ + items, + }); + + const { getByText } = await renderInTestApp( + + + + + , + { + mountedRoutes: { + '/create': catalogRouteRef, + }, + }, + ); + + expect(getByText('OPENAPI')).toBeInTheDocument(); + expect( + queryByText(getByText('OPENAPI').parentElement!, '1'), + ).toBeInTheDocument(); + expect(getByText('SERVICE')).not.toBeInTheDocument(); + expect(getByText('LIBRARY')).not.toBeInTheDocument(); + expect(getByText('SYSTEM')).toBeInTheDocument(); + expect( + queryByText(getByText('SYSTEM').parentElement!, '1'), + ).toBeInTheDocument(); + }); +}); From 5835456f6f52d784f778db4c919e40b6db1e645c Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Sat, 11 Dec 2021 12:52:37 +0100 Subject: [PATCH 17/41] Example for entityFilterKind Signed-off-by: Jan Vilimek --- packages/app/src/components/catalog/EntityPage.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/app/src/components/catalog/EntityPage.tsx b/packages/app/src/components/catalog/EntityPage.tsx index 9810f49386..e6cb43efdc 100644 --- a/packages/app/src/components/catalog/EntityPage.tsx +++ b/packages/app/src/components/catalog/EntityPage.tsx @@ -126,6 +126,8 @@ import { } from '@roadiehq/backstage-plugin-travis-ci'; import React, { ReactNode, useMemo, useState } from 'react'; +const customEntityFilterKind = ['Component', 'API', 'System']; + const EntityLayoutWrapper = (props: { children?: ReactNode }) => { const [badgesDialogOpen, setBadgesDialogOpen] = useState(false); @@ -523,7 +525,7 @@ const userPage = ( - + @@ -539,7 +541,7 @@ const groupPage = ( - + From fc2924b23e4a96c768f4234104b173261cfc0d3d Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Sat, 11 Dec 2021 12:58:53 +0100 Subject: [PATCH 18/41] org plugin changelog Signed-off-by: Jan Vilimek --- plugins/org/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/org/CHANGELOG.md b/plugins/org/CHANGELOG.md index 0576d644da..e409087f1c 100644 --- a/plugins/org/CHANGELOG.md +++ b/plugins/org/CHANGELOG.md @@ -1,5 +1,11 @@ # @backstage/plugin-org +## 0.3.31 + +### Patch Changes + +- added `entityFilterKind` property for `EntityOwnershipCard` + ## 0.3.30 ### Patch Changes From 47755c2a60ffddcf94442fa3483f4c113b3eb176 Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Sat, 11 Dec 2021 12:59:16 +0100 Subject: [PATCH 19/41] package.json 0.3.31 bump Signed-off-by: Jan Vilimek --- plugins/org/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/org/package.json b/plugins/org/package.json index 4e7f556547..3554b5657c 100644 --- a/plugins/org/package.json +++ b/plugins/org/package.json @@ -1,7 +1,7 @@ { "name": "@backstage/plugin-org", "description": "A Backstage plugin that helps you create entity pages for your organization", - "version": "0.3.30", + "version": "0.3.31", "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", From fe86adbcd24282dfae4d4fcd9b2aeb8c4db8c390 Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Sat, 11 Dec 2021 13:05:36 +0100 Subject: [PATCH 20/41] root changelog Signed-off-by: Jan Vilimek --- .changeset/org-ownershipcard-filteradded.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/org-ownershipcard-filteradded.md diff --git a/.changeset/org-ownershipcard-filteradded.md b/.changeset/org-ownershipcard-filteradded.md new file mode 100644 index 0000000000..8f6c1bc37d --- /dev/null +++ b/.changeset/org-ownershipcard-filteradded.md @@ -0,0 +1,6 @@ +--- +"example-app": patch +"@backstage/plugin-org": patch +--- + +Added `entityFilterKind` property for `EntityOwnershipCard` From 75c47f4ee6724348260f03e74c279639e446348a Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Sat, 11 Dec 2021 13:13:37 +0100 Subject: [PATCH 21/41] revert plugin changelog Signed-off-by: Jan Vilimek --- plugins/org/CHANGELOG.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/plugins/org/CHANGELOG.md b/plugins/org/CHANGELOG.md index e409087f1c..0576d644da 100644 --- a/plugins/org/CHANGELOG.md +++ b/plugins/org/CHANGELOG.md @@ -1,11 +1,5 @@ # @backstage/plugin-org -## 0.3.31 - -### Patch Changes - -- added `entityFilterKind` property for `EntityOwnershipCard` - ## 0.3.30 ### Patch Changes From 2fd0010a152fb1b0610e4d8c7bc0511c05a210cf Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Sat, 11 Dec 2021 13:13:58 +0100 Subject: [PATCH 22/41] revert package.json bump Signed-off-by: Jan Vilimek --- plugins/org/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/org/package.json b/plugins/org/package.json index 3554b5657c..4e7f556547 100644 --- a/plugins/org/package.json +++ b/plugins/org/package.json @@ -1,7 +1,7 @@ { "name": "@backstage/plugin-org", "description": "A Backstage plugin that helps you create entity pages for your organization", - "version": "0.3.31", + "version": "0.3.30", "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", From 64dc7ed8c6568e29fb9e22c34febc2695b8172ca Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Mon, 13 Dec 2021 11:11:20 +0100 Subject: [PATCH 23/41] ownershipcard: prettier Signed-off-by: Jan Vilimek --- .../components/Cards/OwnershipCard/OwnershipCard.test.tsx | 2 +- .../src/components/Cards/OwnershipCard/OwnershipCard.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx index e5bf36ba8e..e49720a9d4 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx @@ -352,7 +352,7 @@ describe('OwnershipCardWithCustomFilterDefinition', () => { const { getByText } = await renderInTestApp( - + , { diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx index 56e87a26f6..1e2d514359 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx @@ -128,7 +128,7 @@ const getQueryParams = ( export const OwnershipCard = ({ variant, - entityFilterKind + entityFilterKind, }: { /** @deprecated The entity is now grabbed from context instead */ entity?: Entity; @@ -165,7 +165,9 @@ export const OwnershipCard = ({ const counts = ownedEntitiesList.reduce( (acc: EntityTypeProps[], ownedEntity) => { const match = acc.find( - x => x.kind === ownedEntity.kind && x.type === (ownedEntity.spec?.type ?? ownedEntity.kind), + x => + x.kind === ownedEntity.kind && + x.type === (ownedEntity.spec?.type ?? ownedEntity.kind), ); if (match) { match.count += 1; From 9ed3dfb4d5ff25c676c23a016a6901d812c4ee97 Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Mon, 13 Dec 2021 11:11:42 +0100 Subject: [PATCH 24/41] changelog:prettier Signed-off-by: Jan Vilimek --- .changeset/org-ownershipcard-filteradded.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/org-ownershipcard-filteradded.md b/.changeset/org-ownershipcard-filteradded.md index 8f6c1bc37d..d95428ae02 100644 --- a/.changeset/org-ownershipcard-filteradded.md +++ b/.changeset/org-ownershipcard-filteradded.md @@ -1,6 +1,6 @@ --- -"example-app": patch -"@backstage/plugin-org": patch +'example-app': patch +'@backstage/plugin-org': patch --- Added `entityFilterKind` property for `EntityOwnershipCard` From 8390fff862d6206f6b38bb6ad34b55f3a471fb2b Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Mon, 13 Dec 2021 11:11:56 +0100 Subject: [PATCH 25/41] entitypage: prettier Signed-off-by: Jan Vilimek --- packages/app/src/components/catalog/EntityPage.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/app/src/components/catalog/EntityPage.tsx b/packages/app/src/components/catalog/EntityPage.tsx index e6cb43efdc..a7de64e89a 100644 --- a/packages/app/src/components/catalog/EntityPage.tsx +++ b/packages/app/src/components/catalog/EntityPage.tsx @@ -525,7 +525,10 @@ const userPage = ( - + @@ -541,7 +544,10 @@ const groupPage = ( - + From 9f5a08de13b0b8d925601b98e32bff49fd70b914 Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Mon, 13 Dec 2021 13:29:33 +0100 Subject: [PATCH 26/41] updated api-report Signed-off-by: Jan Vilimek --- plugins/org/api-report.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/org/api-report.md b/plugins/org/api-report.md index 88ce00fd52..60caa45134 100644 --- a/plugins/org/api-report.md +++ b/plugins/org/api-report.md @@ -33,9 +33,11 @@ export const EntityMembersListCard: (_props: { // @public (undocumented) export const EntityOwnershipCard: ({ variant, + entityFilterKind, }: { entity?: Entity | undefined; variant?: InfoCardVariants | undefined; + entityFilterKind?: string[] | undefined; }) => JSX.Element; // Warning: (ae-missing-release-tag) "EntityUserProfileCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -75,9 +77,11 @@ export { orgPlugin as plugin }; // @public (undocumented) export const OwnershipCard: ({ variant, + entityFilterKind, }: { entity?: Entity | undefined; variant?: InfoCardVariants | undefined; + entityFilterKind?: string[] | undefined; }) => JSX.Element; // Warning: (ae-missing-release-tag) "UserProfileCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) From 8ab8c30f1b67b720c09525500476eb21eb2cc4cf Mon Sep 17 00:00:00 2001 From: Balasundaram Date: Mon, 13 Dec 2021 11:10:20 -0500 Subject: [PATCH 27/41] Adding fixes for changeset spelling Signed-off-by: Balasundaram --- .changeset/nervous-hounds-attend.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/nervous-hounds-attend.md b/.changeset/nervous-hounds-attend.md index 15ca4aa085..b54eb5a688 100644 --- a/.changeset/nervous-hounds-attend.md +++ b/.changeset/nervous-hounds-attend.md @@ -2,4 +2,4 @@ '@backstage/plugin-scaffolder-backend': patch --- -Adding changes to create Gitlab Merge Request using custom action +Adding changes to create GitLab Merge Request using custom action From 0be6cb1111b401b8171fa3342c0c9a3a45140f6d Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Mon, 13 Dec 2021 16:17:52 +0100 Subject: [PATCH 28/41] no bump for example-app Signed-off-by: Jan Vilimek --- .changeset/org-ownershipcard-filteradded.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.changeset/org-ownershipcard-filteradded.md b/.changeset/org-ownershipcard-filteradded.md index d95428ae02..cbd1475bb1 100644 --- a/.changeset/org-ownershipcard-filteradded.md +++ b/.changeset/org-ownershipcard-filteradded.md @@ -1,5 +1,4 @@ --- -'example-app': patch '@backstage/plugin-org': patch --- From bc1e2f20bd6a0f3a95aa2a755da0946bd041c1d5 Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Mon, 13 Dec 2021 17:36:09 +0100 Subject: [PATCH 29/41] unit test fixed Signed-off-by: Jan Vilimek --- .../OwnershipCard/OwnershipCard.test.tsx | 225 ++++++------------ 1 file changed, 71 insertions(+), 154 deletions(-) diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx index e49720a9d4..912014092f 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import { GroupEntity, UserEntity } from '@backstage/catalog-model'; +import { Entity, GroupEntity, UserEntity } from '@backstage/catalog-model'; import { CatalogApi, catalogApiRef, @@ -51,6 +51,7 @@ describe('OwnershipCard', () => { const items = [ { + apiVersion: 'backstage.io/v1alpha1', kind: 'API', metadata: { name: 'my-api', @@ -108,23 +109,7 @@ describe('OwnershipCard', () => { }, ], }, - { - kind: 'system', - metadata: { - name: 'my-systen', - }, - relations: [ - { - type: 'ownedBy', - target: { - name: 'my-team', - namespace: 'default', - kind: 'Group', - }, - }, - ], - }, - ] as any; + ] as Entity[]; it('displays entity counts', async () => { const catalogApi: jest.Mocked = { @@ -148,6 +133,17 @@ describe('OwnershipCard', () => { }, ); + expect(catalogApi.getEntities).toHaveBeenCalledWith({ + filter: { kind: ['Component', 'API'] }, + fields: [ + 'kind', + 'metadata.name', + 'metadata.namespace', + 'spec.type', + 'relations', + ], + }); + expect(getByText('OPENAPI')).toBeInTheDocument(); expect( queryByText(getByText('OPENAPI').parentElement!, '1'), @@ -160,7 +156,63 @@ describe('OwnershipCard', () => { expect( queryByText(getByText('LIBRARY').parentElement!, '1'), ).toBeInTheDocument(); - expect(getByText('SYSTEM')).not.toBeInTheDocument(); + }); + + it('applies CustomFilterDefinition', async () => { + const catalogApi: jest.Mocked = { + getEntities: jest.fn(), + } as any; + + catalogApi.getEntities.mockResolvedValue({ + items: [ + { + apiVersion: 'backstage.io/v1alpha1', + kind: 'system', + metadata: { + name: 'my-systen', + }, + relations: [ + { + type: 'ownedBy', + target: { + name: 'my-team', + namespace: 'default', + kind: 'Group', + }, + }, + ], + }, + ], + }); + + const { getByText } = await renderInTestApp( + + + + + , + { + mountedRoutes: { + '/create': catalogRouteRef, + }, + }, + ); + + expect(catalogApi.getEntities).toHaveBeenCalledWith({ + filter: { kind: ['API', 'System'] }, + fields: [ + 'kind', + 'metadata.name', + 'metadata.namespace', + 'spec.type', + 'relations', + ], + }); + + expect(getByText('SYSTEM')).toBeInTheDocument(); + expect( + queryByText(getByText('SYSTEM').parentElement!, '1'), + ).toBeInTheDocument(); }); it('links to the catalog with the group filter', async () => { @@ -239,138 +291,3 @@ describe('OwnershipCard', () => { ); }); }); - -describe('OwnershipCardWithCustomFilterDefinition', () => { - const groupEntity: GroupEntity = { - apiVersion: 'backstage.io/v1alpha1', - kind: 'Group', - metadata: { - name: 'my-team', - }, - spec: { - type: 'team', - children: [], - }, - relations: [ - { - type: 'memberOf', - target: { - kind: 'group', - name: 'ExampleGroup', - namespace: 'default', - }, - }, - ], - }; - - const items = [ - { - kind: 'API', - metadata: { - name: 'my-api', - }, - spec: { - type: 'openapi', - }, - relations: [ - { - type: 'ownedBy', - target: { - name: 'my-team', - namespace: 'default', - kind: 'Group', - }, - }, - ], - }, - { - kind: 'Component', - metadata: { - name: 'my-service', - }, - spec: { - type: 'service', - }, - relations: [ - { - type: 'ownedBy', - target: { - name: 'my-team', - namespace: 'default', - kind: 'Group', - }, - }, - ], - }, - { - kind: 'Component', - metadata: { - name: 'my-library', - namespace: 'other-namespace', - }, - spec: { - type: 'library', - }, - relations: [ - { - type: 'ownedBy', - target: { - name: 'my-team', - namespace: 'default', - kind: 'Group', - }, - }, - ], - }, - { - kind: 'system', - metadata: { - name: 'my-systen', - }, - relations: [ - { - type: 'ownedBy', - target: { - name: 'my-team', - namespace: 'default', - kind: 'Group', - }, - }, - ], - }, - ] as any; - - it('displays entity counts', async () => { - const catalogApi: jest.Mocked = { - getEntities: jest.fn(), - } as any; - - catalogApi.getEntities.mockResolvedValue({ - items, - }); - - const { getByText } = await renderInTestApp( - - - - - , - { - mountedRoutes: { - '/create': catalogRouteRef, - }, - }, - ); - - expect(getByText('OPENAPI')).toBeInTheDocument(); - expect( - queryByText(getByText('OPENAPI').parentElement!, '1'), - ).toBeInTheDocument(); - expect(getByText('SERVICE')).not.toBeInTheDocument(); - expect(getByText('LIBRARY')).not.toBeInTheDocument(); - expect(getByText('SYSTEM')).toBeInTheDocument(); - expect( - queryByText(getByText('SYSTEM').parentElement!, '1'), - ).toBeInTheDocument(); - }); -}); From 201953b21ebc7adc2ae5f282bcacdc84a67e0084 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 13 Dec 2021 23:26:06 +0100 Subject: [PATCH 30/41] workflows/stale: bump PR close days to 5 Signed-off-by: Patrik Oldsberg --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 96a2a20109..5cbf4e32ef 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -24,7 +24,7 @@ jobs: recent activity from the author. It will be closed if no further activity occurs. If you are the author and the PR has been closed, feel free to re-open the PR and continue the contribution! days-before-pr-stale: 7 - days-before-pr-close: 3 + days-before-pr-close: 5 exempt-pr-labels: reviewer-approved,awaiting-review stale-pr-label: stale operations-per-run: 100 From b5fb3dbc9e09ea85d4f01ca332cd6854d2177f68 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Dec 2021 04:23:04 +0000 Subject: [PATCH 31/41] build(deps): bump @types/ldapjs from 2.2.0 to 2.2.2 Bumps [@types/ldapjs](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/ldapjs) from 2.2.0 to 2.2.2. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/ldapjs) --- updated-dependencies: - dependency-name: "@types/ldapjs" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- yarn.lock | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/yarn.lock b/yarn.lock index 19f6ad2b27..4e77c271b6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7756,9 +7756,9 @@ "@types/node" "*" "@types/ldapjs@^2.2.0": - version "2.2.0" - resolved "https://registry.npmjs.org/@types/ldapjs/-/ldapjs-2.2.0.tgz#43ff78668c420b69a61b93e0acde71ddc0c7766d" - integrity sha512-L6ObSryRGOw0qYmN9B4w4s8UkoyRbxoWh7C1vc/Z6O/VXJQJqGBSyZPXRDmgKF+TZVGq/F7H37t0Cxrm+hLiRA== + version "2.2.2" + resolved "https://registry.npmjs.org/@types/ldapjs/-/ldapjs-2.2.2.tgz#cf79510d8dc34e5579442c2743f8a228427eb99c" + integrity sha512-U5HdnwIZ5uZa+f3usxdqgyfNmOROxOxXvQdQtsu6sKo8fte5vej9br2csHxPvXreAbAO1bs8/rdEzvCLpi67nQ== dependencies: "@types/node" "*" @@ -7897,36 +7897,31 @@ "@types/node" "*" form-data "^3.0.0" -"@types/node@*", "@types/node@>= 8", "@types/node@>=12.12.47", "@types/node@>=13.7.0", "@types/node@^14.0.10", "@types/node@^14.14.31", "@types/node@^14.14.32": - version "14.17.8" - resolved "https://registry.npmjs.org/@types/node/-/node-14.17.8.tgz#813b73ab7d82ac06ddfd2458b13c88459a3b319f" - integrity sha512-0CHLt50GbUmH/6MrlBIKNdWCglvlyQKkorRf08/0DIi0ryuTPP+ijWLSI19SbDTHSKaagGDELiImY4BSikt61w== +"@types/node@*", "@types/node@>= 8", "@types/node@>=12.12.47", "@types/node@>=13.7.0", "@types/node@^16.9.2": + version "16.11.6" + resolved "https://registry.npmjs.org/@types/node/-/node-16.11.6.tgz#6bef7a2a0ad684cf6e90fcfe31cecabd9ce0a3ae" + integrity sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w== "@types/node@10.17.13", "@types/node@^10.1.0", "@types/node@^10.12.0": version "10.17.13" resolved "https://registry.npmjs.org/@types/node/-/node-10.17.13.tgz#ccebcdb990bd6139cd16e84c39dc2fb1023ca90c" integrity sha512-pMCcqU2zT4TjqYFrWtYHKal7Sl30Ims6ulZ4UFXxI4xbtQqK/qqKwkDoBFCfooRqqmRu9vY3xaJRwxSh673aYg== -"@types/node@12.20.24": +"@types/node@12.20.24", "@types/node@^12.7.1": version "12.20.24" resolved "https://registry.npmjs.org/@types/node/-/node-12.20.24.tgz#c37ac69cb2948afb4cef95f424fa0037971a9a5c" integrity sha512-yxDeaQIAJlMav7fH5AQqPH1u8YIuhYJXYBzxaQ4PifsU0GDO38MSdmEDeRlIxrKbC6NbEaaEHDanWb+y30U8SQ== -"@types/node@^12.7.1": - version "12.12.58" - resolved "https://registry.npmjs.org/@types/node/-/node-12.12.58.tgz#46dae9b2b9ee5992818c8f7cee01ff4ce03ab44c" - integrity sha512-Be46CNIHWAagEfINOjmriSxuv7IVcqbGe+sDSg2SYCEz/0CRBy7LRASGfRbD8KZkqoePU73Wsx3UvOSFcq/9hA== +"@types/node@^14.0.10", "@types/node@^14.14.31", "@types/node@^14.14.32": + version "14.17.8" + resolved "https://registry.npmjs.org/@types/node/-/node-14.17.8.tgz#813b73ab7d82ac06ddfd2458b13c88459a3b319f" + integrity sha512-0CHLt50GbUmH/6MrlBIKNdWCglvlyQKkorRf08/0DIi0ryuTPP+ijWLSI19SbDTHSKaagGDELiImY4BSikt61w== "@types/node@^15.6.1": version "15.14.9" resolved "https://registry.npmjs.org/@types/node/-/node-15.14.9.tgz#bc43c990c3c9be7281868bbc7b8fdd6e2b57adfa" integrity sha512-qjd88DrCxupx/kJD5yQgZdcYKZKSIGBVDIBE1/LTGcNm3d2Np/jxojkdePDdfnBHJc5W7vSMpbJ1aB7p/Py69A== -"@types/node@^16.9.2": - version "16.11.6" - resolved "https://registry.npmjs.org/@types/node/-/node-16.11.6.tgz#6bef7a2a0ad684cf6e90fcfe31cecabd9ce0a3ae" - integrity sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w== - "@types/normalize-package-data@^2.4.0": version "2.4.0" resolved "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" From 39553c13576738a4c4de79ec92122b4db9ec6ee3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Dec 2021 04:23:56 +0000 Subject: [PATCH 32/41] build(deps): bump eslint-plugin-import from 2.22.1 to 2.25.3 Bumps [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import) from 2.22.1 to 2.25.3. - [Release notes](https://github.com/import-js/eslint-plugin-import/releases) - [Changelog](https://github.com/import-js/eslint-plugin-import/blob/main/CHANGELOG.md) - [Commits](https://github.com/import-js/eslint-plugin-import/compare/v2.22.1...v2.25.3) --- updated-dependencies: - dependency-name: eslint-plugin-import dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- yarn.lock | 144 ++++++++++++++++++++---------------------------------- 1 file changed, 53 insertions(+), 91 deletions(-) diff --git a/yarn.lock b/yarn.lock index 19f6ad2b27..f202ed7318 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9757,13 +9757,14 @@ array-unique@^0.3.2: resolved "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= -array.prototype.flat@^1.2.1, array.prototype.flat@^1.2.3: - version "1.2.3" - resolved "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.3.tgz#0de82b426b0318dbfdb940089e38b043d37f6c7b" - integrity sha512-gBlRZV0VSmfPIeWfuuy56XZMvbVfbEUnOXUvt3F/eUUUSyzlgLxhEX4YAEpxNAogRGehPSnfXyPtYyKAhkzQhQ== +array.prototype.flat@^1.2.1, array.prototype.flat@^1.2.5: + version "1.2.5" + resolved "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.5.tgz#07e0975d84bbc7c48cd1879d609e682598d33e13" + integrity sha512-KaYU+S+ndVqyUnignHftkwc58o3uVU1jzczILJ1tN2YaIZpFIKBiP/x/j97E5MVPsaCloPbqWLB/8qCTVvT2qg== dependencies: + call-bind "^1.0.2" define-properties "^1.1.3" - es-abstract "^1.17.0-next.1" + es-abstract "^1.19.0" array.prototype.flatmap@^1.2.1, array.prototype.flatmap@^1.2.4, array.prototype.flatmap@^1.2.5: version "1.2.5" @@ -11939,11 +11940,6 @@ constants-browserify@^1.0.0: resolved "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" integrity sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U= -contains-path@^0.1.0: - version "0.1.0" - resolved "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a" - integrity sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo= - content-disposition@0.5.2: version "0.5.2" resolved "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz#0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4" @@ -13042,10 +13038,10 @@ debug@4.3.1: dependencies: ms "2.1.2" -debug@^3.0.0, debug@^3.1.0, debug@^3.1.1, debug@^3.2.6: - version "3.2.6" - resolved "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" - integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== +debug@^3.0.0, debug@^3.1.0, debug@^3.1.1, debug@^3.2.6, debug@^3.2.7: + version "3.2.7" + resolved "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" + integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== dependencies: ms "^2.1.1" @@ -13436,14 +13432,6 @@ dockerode@^3.3.1: docker-modem "^3.0.0" tar-fs "~2.0.1" -doctrine@1.5.0: - version "1.5.0" - resolved "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa" - integrity sha1-N53Ocw9hZvds76TmcHoVmwLFpvo= - dependencies: - esutils "^2.0.2" - isarray "^1.0.0" - doctrine@^2.1.0: version "2.1.0" resolved "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" @@ -14234,20 +14222,21 @@ eslint-formatter-friendly@^7.0.0: strip-ansi "5.2.0" text-table "0.2.0" -eslint-import-resolver-node@^0.3.4: - version "0.3.4" - resolved "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz#85ffa81942c25012d8231096ddf679c03042c717" - integrity sha512-ogtf+5AB/O+nM6DIeBUNr2fuT7ot9Qg/1harBfBtaP13ekEWFQEEMP94BCB7zaNW3gyY+8SHYF00rnqYwXKWOA== +eslint-import-resolver-node@^0.3.6: + version "0.3.6" + resolved "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz#4048b958395da89668252001dbd9eca6b83bacbd" + integrity sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw== dependencies: - debug "^2.6.9" - resolve "^1.13.1" + debug "^3.2.7" + resolve "^1.20.0" -eslint-module-utils@^2.1.1, eslint-module-utils@^2.6.0: - version "2.6.0" - resolved "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz#579ebd094f56af7797d19c9866c9c9486629bfa6" - integrity sha512-6j9xxegbqe8/kZY8cYpcp0xhbK0EgJlg3g9mib3/miLaExuuwc3n5UEfSnU6hWMbT0FAYVvDbL9RrRgpUeQIvA== +eslint-module-utils@^2.1.1, eslint-module-utils@^2.7.1: + version "2.7.1" + resolved "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.1.tgz#b435001c9f8dd4ab7f6d0efcae4b9696d4c24b7c" + integrity sha512-fjoetBXQZq2tSTWZ9yWVl2KuFrTZZH3V+9iD1V1RfpDgxzJR+mPd/KZmMiA8gbPqdBzpNiEHOuT7IYEWxrH0zQ== dependencies: - debug "^2.6.9" + debug "^3.2.7" + find-up "^2.1.0" pkg-dir "^2.0.0" eslint-plugin-cypress@^2.10.3: @@ -14268,23 +14257,23 @@ eslint-plugin-graphql@^4.0.0: lodash.without "^4.4.0" eslint-plugin-import@^2.20.2: - version "2.22.1" - resolved "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz#0896c7e6a0cf44109a2d97b95903c2bb689d7702" - integrity sha512-8K7JjINHOpH64ozkAhpT3sd+FswIZTfMZTjdx052pnWrgRCVfp8op9tbjpAk3DdUeI/Ba4C8OjdC0r90erHEOw== + version "2.25.3" + resolved "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.25.3.tgz#a554b5f66e08fb4f6dc99221866e57cfff824766" + integrity sha512-RzAVbby+72IB3iOEL8clzPLzL3wpDrlwjsTBAQXgyp5SeTqqY+0bFubwuo+y/HLhNZcXV4XqTBO4LGsfyHIDXg== dependencies: - array-includes "^3.1.1" - array.prototype.flat "^1.2.3" - contains-path "^0.1.0" + array-includes "^3.1.4" + array.prototype.flat "^1.2.5" debug "^2.6.9" - doctrine "1.5.0" - eslint-import-resolver-node "^0.3.4" - eslint-module-utils "^2.6.0" + doctrine "^2.1.0" + eslint-import-resolver-node "^0.3.6" + eslint-module-utils "^2.7.1" has "^1.0.3" + is-core-module "^2.8.0" + is-glob "^4.0.3" minimatch "^3.0.4" - object.values "^1.1.1" - read-pkg-up "^2.0.0" - resolve "^1.17.0" - tsconfig-paths "^3.9.0" + object.values "^1.1.5" + resolve "^1.20.0" + tsconfig-paths "^3.11.0" eslint-plugin-jest@^24.1.0: version "24.3.6" @@ -17524,10 +17513,10 @@ is-ci@^3.0.0: dependencies: ci-info "^3.1.1" -is-core-module@^2.1.0, is-core-module@^2.2.0: - version "2.4.0" - resolved "https://registry.npmjs.org/is-core-module/-/is-core-module-2.4.0.tgz#8e9fc8e15027b011418026e98f0e6f4d86305cc1" - integrity sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A== +is-core-module@^2.1.0, is-core-module@^2.2.0, is-core-module@^2.8.0: + version "2.8.0" + resolved "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.0.tgz#0321336c3d0925e497fd97f5d95cb114a5ccd548" + integrity sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw== dependencies: has "^1.0.3" @@ -17650,7 +17639,7 @@ is-generator-function@^1.0.7: resolved "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.8.tgz#dfb5c2b120e02b0a8d9d2c6806cd5621aa922f7b" integrity sha512-2Omr/twNtufVZFr1GhxjOMFPAj2sjc/dKaIqBhvo4qciXfJmITGH6ZGd8eZYNHza8t1y0e01AuqRhJwfWp26WQ== -is-glob@4.0.1, is-glob@^4.0.0, is-glob@^4.0.1, is-glob@~4.0.1: +is-glob@4.0.1: version "4.0.1" resolved "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== @@ -17671,6 +17660,13 @@ is-glob@^3.0.0, is-glob@^3.1.0: dependencies: is-extglob "^2.1.0" +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: + version "4.0.3" + resolved "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + is-hexadecimal@^1.0.0: version "1.0.4" resolved "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.4.tgz#cc35c97588da4bd49a8eedd6bc4082d44dcb23a7" @@ -19668,16 +19664,6 @@ load-json-file@^1.0.0: pinkie-promise "^2.0.0" strip-bom "^2.0.0" -load-json-file@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8" - integrity sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg= - dependencies: - graceful-fs "^4.1.2" - parse-json "^2.2.0" - pify "^2.0.0" - strip-bom "^3.0.0" - load-json-file@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" @@ -22231,7 +22217,7 @@ object.pick@^1.3.0: dependencies: isobject "^3.0.1" -object.values@^1.1.0, object.values@^1.1.1, object.values@^1.1.5: +object.values@^1.1.0, object.values@^1.1.5: version "1.1.5" resolved "https://registry.npmjs.org/object.values/-/object.values-1.1.5.tgz#959f63e3ce9ef108720333082131e4a459b716ac" integrity sha512-QUZRW0ilQ3PnPpbNtgdNV1PDbEqLIiSFB3l+EnGtBQ/8SUTLj1PZwtQHABZtLgwpJZTSZhuGLOGk57Drx2IvYg== @@ -23066,13 +23052,6 @@ path-type@^1.0.0: pify "^2.0.0" pinkie-promise "^2.0.0" -path-type@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73" - integrity sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM= - dependencies: - pify "^2.0.0" - path-type@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" @@ -24930,14 +24909,6 @@ read-pkg-up@^1.0.1: find-up "^1.0.0" read-pkg "^1.0.0" -read-pkg-up@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz#6b72a8048984e0c41e79510fd5e9fa99b3b549be" - integrity sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4= - dependencies: - find-up "^2.0.0" - read-pkg "^2.0.0" - read-pkg-up@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz#3ed496685dba0f8fe118d0691dc51f4a1ff96f07" @@ -24964,15 +24935,6 @@ read-pkg@^1.0.0: normalize-package-data "^2.3.2" path-type "^1.0.0" -read-pkg@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz#8ef1c0623c6a6db0dc6713c4bfac46332b2368f8" - integrity sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg= - dependencies: - load-json-file "^2.0.0" - normalize-package-data "^2.3.2" - path-type "^2.0.0" - read-pkg@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389" @@ -25612,7 +25574,7 @@ resolve-url@^0.2.1: resolved "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= -resolve@^1.1.6, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.18.1, resolve@^1.19.0, resolve@^1.3.2, resolve@^1.9.0: +resolve@^1.1.6, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.18.1, resolve@^1.19.0, resolve@^1.20.0, resolve@^1.3.2, resolve@^1.9.0: version "1.20.0" resolved "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== @@ -28263,10 +28225,10 @@ ts-pnp@^1.1.6: resolved "https://registry.npmjs.org/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92" integrity sha512-csd+vJOb/gkzvcCHgTGSChYpy5f1/XKNsmvBGO4JXS+z1v2HobugDz4s1IeFXM3wZB44uczs+eazB5Q/ccdhQw== -tsconfig-paths@^3.9.0: - version "3.9.0" - resolved "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz#098547a6c4448807e8fcb8eae081064ee9a3c90b" - integrity sha512-dRcuzokWhajtZWkQsDVKbWyY+jgcLC5sqJhg2PSgf4ZkH2aHPvaOY8YWGhmjb68b5qqTfasSsDO9k7RUiEmZAw== +tsconfig-paths@^3.11.0: + version "3.12.0" + resolved "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.12.0.tgz#19769aca6ee8f6a1a341e38c8fa45dd9fb18899b" + integrity sha512-e5adrnOYT6zqVnWqZu7i/BQ3BnhzvGbjEjejFXO20lKIKpwTaupkCPgEfv4GZK1IBciJUEhYs3J3p75FdaTFVg== dependencies: "@types/json5" "^0.0.29" json5 "^1.0.1" From 1680a1c5ac061e58a0d1146310d4de10a00f33d1 Mon Sep 17 00:00:00 2001 From: Dede Hamzah Date: Tue, 14 Dec 2021 15:09:32 +0700 Subject: [PATCH 33/41] Add Missing Overridable Components Type for SidebarSpace, SidebarSpacer, and SidebarDivider Components Signed-off-by: Dede Hamzah --- .changeset/stupid-mice-dream.md | 5 +++++ packages/core-components/src/layout/Sidebar/Items.tsx | 6 ++++++ packages/core-components/src/layout/Sidebar/index.ts | 7 ++++++- packages/core-components/src/overridableComponents.ts | 6 ++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .changeset/stupid-mice-dream.md diff --git a/.changeset/stupid-mice-dream.md b/.changeset/stupid-mice-dream.md new file mode 100644 index 0000000000..17d2609585 --- /dev/null +++ b/.changeset/stupid-mice-dream.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-components': patch +--- + +Add Missing Overridable Components Type for SidebarSpace, SidebarSpacer, and SidebarDivider Components. diff --git a/packages/core-components/src/layout/Sidebar/Items.tsx b/packages/core-components/src/layout/Sidebar/Items.tsx index c8c6db13a2..dac35bd3a7 100644 --- a/packages/core-components/src/layout/Sidebar/Items.tsx +++ b/packages/core-components/src/layout/Sidebar/Items.tsx @@ -548,6 +548,8 @@ export function SidebarSearchField(props: SidebarSearchFieldProps) { ); } +export type SidebarSpaceClassKey = 'root'; + export const SidebarSpace = styled('div')( { flex: 1, @@ -555,6 +557,8 @@ export const SidebarSpace = styled('div')( { name: 'BackstageSidebarSpace' }, ); +export type SidebarSpacerClassKey = 'root'; + export const SidebarSpacer = styled('div')( { height: 8, @@ -562,6 +566,8 @@ export const SidebarSpacer = styled('div')( { name: 'BackstageSidebarSpacer' }, ); +export type SidebarDividerClassKey = 'root'; + export const SidebarDivider = styled('hr')( { height: 1, diff --git a/packages/core-components/src/layout/Sidebar/index.ts b/packages/core-components/src/layout/Sidebar/index.ts index 79a86023ee..3d922f1322 100644 --- a/packages/core-components/src/layout/Sidebar/index.ts +++ b/packages/core-components/src/layout/Sidebar/index.ts @@ -33,7 +33,12 @@ export { SidebarSpacer, SidebarScrollWrapper, } from './Items'; -export type { SidebarItemClassKey } from './Items'; +export type { + SidebarItemClassKey, + SidebarSpaceClassKey, + SidebarSpacerClassKey, + SidebarDividerClassKey, +} from './Items'; export { IntroCard, SidebarIntro } from './Intro'; export type { SidebarIntroClassKey } from './Intro'; export { diff --git a/packages/core-components/src/overridableComponents.ts b/packages/core-components/src/overridableComponents.ts index 98b8f83abd..c53c47da1b 100644 --- a/packages/core-components/src/overridableComponents.ts +++ b/packages/core-components/src/overridableComponents.ts @@ -83,6 +83,9 @@ import { ItemCardHeaderClassKey, PageClassKey, SidebarClassKey, + SidebarSpaceClassKey, + SidebarSpacerClassKey, + SidebarDividerClassKey, SidebarIntroClassKey, SidebarItemClassKey, SidebarPageClassKey, @@ -157,6 +160,9 @@ type BackstageComponentsNameToClassKey = { BackstageItemCardHeader: ItemCardHeaderClassKey; BackstagePage: PageClassKey; BackstageSidebar: SidebarClassKey; + BackstageSidebarSpace: SidebarSpaceClassKey; + BackstageSidebarSpacer: SidebarSpacerClassKey; + BackstageSidebarDivider: SidebarDividerClassKey; BackstageSidebarIntro: SidebarIntroClassKey; BackstageSidebarItem: SidebarItemClassKey; BackstageSidebarPage: SidebarPageClassKey; From 9c0265a6aa9827f0640c97c1c3ad845f4199e6d4 Mon Sep 17 00:00:00 2001 From: Dede Hamzah Date: Tue, 14 Dec 2021 16:37:13 +0700 Subject: [PATCH 34/41] Update changeset to fix failed Vale Signed-off-by: Dede Hamzah --- .changeset/stupid-mice-dream.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/stupid-mice-dream.md b/.changeset/stupid-mice-dream.md index 17d2609585..2cd2b4e067 100644 --- a/.changeset/stupid-mice-dream.md +++ b/.changeset/stupid-mice-dream.md @@ -2,4 +2,4 @@ '@backstage/core-components': patch --- -Add Missing Overridable Components Type for SidebarSpace, SidebarSpacer, and SidebarDivider Components. +Add Missing Override Components Type for SidebarSpace, SidebarSpacer, and SidebarDivider Components. From 5b54d634778bc962a4e90c20d6b77aef3c9280cb Mon Sep 17 00:00:00 2001 From: Dede Hamzah Date: Tue, 14 Dec 2021 16:53:31 +0700 Subject: [PATCH 35/41] Add missing api report Signed-off-by: Dede Hamzah --- packages/core-components/api-report.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/core-components/api-report.md b/packages/core-components/api-report.md index d098403113..e12a6e04fe 100644 --- a/packages/core-components/api-report.md +++ b/packages/core-components/api-report.md @@ -1152,6 +1152,11 @@ export const SidebarDivider: React_2.ComponentType< } >; +// Warning: (ae-missing-release-tag) "SidebarDividerClassKey" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type SidebarDividerClassKey = 'root'; + // @public export const SidebarExpandButton: () => JSX.Element | null; @@ -1760,6 +1765,11 @@ export const SidebarSpace: React_2.ComponentType< } >; +// Warning: (ae-missing-release-tag) "SidebarSpaceClassKey" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type SidebarSpaceClassKey = 'root'; + // Warning: (ae-missing-release-tag) "SidebarSpacer" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -2029,6 +2039,11 @@ export const SidebarSpacer: React_2.ComponentType< } >; +// Warning: (ae-missing-release-tag) "SidebarSpacerClassKey" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type SidebarSpacerClassKey = 'root'; + // @public export const SidebarSubmenu: (props: SidebarSubmenuProps) => JSX.Element; From 60abfd536aaf070d4249f1c383a3719abb8f45ea Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Tue, 14 Dec 2021 19:04:51 +0100 Subject: [PATCH 36/41] Improved unit tests Signed-off-by: Jan Vilimek --- plugins/org/package.json | 1 + .../OwnershipCard/OwnershipCard.test.tsx | 208 +++++++++--------- 2 files changed, 106 insertions(+), 103 deletions(-) diff --git a/plugins/org/package.json b/plugins/org/package.json index 4e7f556547..8df865f386 100644 --- a/plugins/org/package.json +++ b/plugins/org/package.json @@ -40,6 +40,7 @@ "devDependencies": { "@backstage/cli": "^0.10.1", "@backstage/core-app-api": "^0.2.0", + "@backstage/catalog-client": "^0.5.2", "@backstage/dev-utils": "^0.2.14", "@backstage/test-utils": "^0.1.24", "@testing-library/jest-dom": "^5.10.1", diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx index 912014092f..c4710c14ab 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx @@ -14,6 +14,10 @@ * limitations under the License. */ +import { + CatalogEntitiesRequest, + CatalogListResponse, +} from '@backstage/catalog-client'; import { Entity, GroupEntity, UserEntity } from '@backstage/catalog-model'; import { CatalogApi, @@ -26,6 +30,97 @@ import { queryByText } from '@testing-library/react'; import React from 'react'; import { OwnershipCard } from './OwnershipCard'; +const items = [ + { + apiVersion: 'backstage.io/v1alpha1', + kind: 'API', + metadata: { + name: 'my-api', + }, + spec: { + type: 'openapi', + }, + relations: [ + { + type: 'ownedBy', + target: { + name: 'my-team', + namespace: 'default', + kind: 'Group', + }, + }, + ], + }, + { + kind: 'Component', + metadata: { + name: 'my-service', + }, + spec: { + type: 'service', + }, + relations: [ + { + type: 'ownedBy', + target: { + name: 'my-team', + namespace: 'default', + kind: 'Group', + }, + }, + ], + }, + { + kind: 'Component', + metadata: { + name: 'my-library', + namespace: 'other-namespace', + }, + spec: { + type: 'library', + }, + relations: [ + { + type: 'ownedBy', + target: { + name: 'my-team', + namespace: 'default', + kind: 'Group', + }, + }, + ], + }, + { + apiVersion: 'backstage.io/v1alpha1', + kind: 'System', + metadata: { + name: 'my-system', + }, + relations: [ + { + type: 'ownedBy', + target: { + name: 'my-team', + namespace: 'default', + kind: 'Group', + }, + }, + ], + }, +] as Entity[]; + +const getEntitiesMock = ( + request?: CatalogEntitiesRequest, +): Promise> => { + const filterKinds = + !Array.isArray(request?.filter) && Array.isArray(request?.filter?.kind) + ? request?.filter?.kind ?? [] + : []; // we expect the request to be like { filter: { kind: ['API','System'], .... } + return Promise.resolve({ + items: items.filter(item => filterKinds.find(k => k === item.kind)), + } as CatalogListResponse); +}; + describe('OwnershipCard', () => { const groupEntity: GroupEntity = { apiVersion: 'backstage.io/v1alpha1', @@ -49,76 +144,12 @@ describe('OwnershipCard', () => { ], }; - const items = [ - { - apiVersion: 'backstage.io/v1alpha1', - kind: 'API', - metadata: { - name: 'my-api', - }, - spec: { - type: 'openapi', - }, - relations: [ - { - type: 'ownedBy', - target: { - name: 'my-team', - namespace: 'default', - kind: 'Group', - }, - }, - ], - }, - { - kind: 'Component', - metadata: { - name: 'my-service', - }, - spec: { - type: 'service', - }, - relations: [ - { - type: 'ownedBy', - target: { - name: 'my-team', - namespace: 'default', - kind: 'Group', - }, - }, - ], - }, - { - kind: 'Component', - metadata: { - name: 'my-library', - namespace: 'other-namespace', - }, - spec: { - type: 'library', - }, - relations: [ - { - type: 'ownedBy', - target: { - name: 'my-team', - namespace: 'default', - kind: 'Group', - }, - }, - ], - }, - ] as Entity[]; - it('displays entity counts', async () => { const catalogApi: jest.Mocked = { getEntities: jest.fn(), } as any; - catalogApi.getEntities.mockResolvedValue({ - items, - }); + catalogApi.getEntities.mockImplementation(getEntitiesMock); const { getByText } = await renderInTestApp( @@ -156,6 +187,7 @@ describe('OwnershipCard', () => { expect( queryByText(getByText('LIBRARY').parentElement!, '1'), ).toBeInTheDocument(); + expect(() => getByText('SYSTEM')).toThrowError(); }); it('applies CustomFilterDefinition', async () => { @@ -163,27 +195,7 @@ describe('OwnershipCard', () => { getEntities: jest.fn(), } as any; - catalogApi.getEntities.mockResolvedValue({ - items: [ - { - apiVersion: 'backstage.io/v1alpha1', - kind: 'system', - metadata: { - name: 'my-systen', - }, - relations: [ - { - type: 'ownedBy', - target: { - name: 'my-team', - namespace: 'default', - kind: 'Group', - }, - }, - ], - }, - ], - }); + catalogApi.getEntities.mockImplementation(getEntitiesMock); const { getByText } = await renderInTestApp( @@ -198,21 +210,15 @@ describe('OwnershipCard', () => { }, ); - expect(catalogApi.getEntities).toHaveBeenCalledWith({ - filter: { kind: ['API', 'System'] }, - fields: [ - 'kind', - 'metadata.name', - 'metadata.namespace', - 'spec.type', - 'relations', - ], - }); - expect(getByText('SYSTEM')).toBeInTheDocument(); expect( queryByText(getByText('SYSTEM').parentElement!, '1'), ).toBeInTheDocument(); + expect(getByText('OPENAPI')).toBeInTheDocument(); + expect( + queryByText(getByText('OPENAPI').parentElement!, '1'), + ).toBeInTheDocument(); + expect(() => getByText('LIBRARY')).toThrowError(); }); it('links to the catalog with the group filter', async () => { @@ -220,9 +226,7 @@ describe('OwnershipCard', () => { getEntities: jest.fn(), } as any; - catalogApi.getEntities.mockResolvedValue({ - items, - }); + catalogApi.getEntities.mockImplementation(getEntitiesMock); const { getByText } = await renderInTestApp( @@ -268,9 +272,7 @@ describe('OwnershipCard', () => { getEntities: jest.fn(), } as any; - catalogApi.getEntities.mockResolvedValue({ - items, - }); + catalogApi.getEntities.mockImplementation(getEntitiesMock); const { getByText } = await renderInTestApp( From 813db5928bf1bff5a4ee15fa63608c86c99292cc Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 15 Dec 2021 01:17:58 +0100 Subject: [PATCH 37/41] core-plugin-api: document ErrorApiErrorContext.hidden MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Co-authored-by: Johan Haals Signed-off-by: Patrik Oldsberg --- .../core-plugin-api/src/apis/definitions/ErrorApi.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/core-plugin-api/src/apis/definitions/ErrorApi.ts b/packages/core-plugin-api/src/apis/definitions/ErrorApi.ts index 45ee0901c8..364a7bd29a 100644 --- a/packages/core-plugin-api/src/apis/definitions/ErrorApi.ts +++ b/packages/core-plugin-api/src/apis/definitions/ErrorApi.ts @@ -41,7 +41,15 @@ export type Error = ErrorApiError; * @public */ export type ErrorApiErrorContext = { - // If set to true, this error should not be displayed to the user. Defaults to false. + /** + * If set to true, this error should not be displayed to the user. + * + * Hidden errors are typically not displayed in the UI, but the ErrorApi + * implementation may still report them to error tracking services + * or other utilities that care about all errors. + * + * @defaultValue false + */ hidden?: boolean; }; From 12f674f60825aa2079bd756e895fc632e4742156 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 15 Dec 2021 01:39:47 +0100 Subject: [PATCH 38/41] package.json: fix duplicate api-extractor installs Signed-off-by: Patrik Oldsberg --- package.json | 7 +-- yarn.lock | 143 ++++++++++++++++++++------------------------------- 2 files changed, 61 insertions(+), 89 deletions(-) diff --git a/package.json b/package.json index 3a20ce7f8e..57cf603090 100644 --- a/package.json +++ b/package.json @@ -55,9 +55,9 @@ }, "version": "1.0.0", "dependencies": { - "@microsoft/api-documenter": "^7.13.68", - "@microsoft/api-extractor": "^7.18.7", - "@microsoft/api-extractor-model": "^7.13.5", + "@microsoft/api-documenter": "^7.13.77", + "@microsoft/api-extractor": "^7.19.2", + "@microsoft/api-extractor-model": "^7.15.1", "@microsoft/tsdoc": "^0.13.2" }, "devDependencies": { @@ -78,6 +78,7 @@ "prettier": "^2.2.1", "shx": "^0.3.2", "ts-node": "^10.4.0", + "typescript": "~4.3.5", "yarn-lock-check": "^1.0.5" }, "prettier": "@spotify/prettier-config", diff --git a/yarn.lock b/yarn.lock index 0a47ca410c..61ab32bf3e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4846,54 +4846,45 @@ resolved "https://registry.npmjs.org/@mdx-js/util/-/util-1.6.22.tgz#219dfd89ae5b97a8801f015323ffa4b62f45718b" integrity sha512-H1rQc1ZOHANWBvPcW+JpGwr+juXSxM8Q8YCkm3GhZd8REu1fHR3z99CErO1p9pkcfcxZnMdIZdIsXkOHY0NilA== -"@microsoft/api-documenter@^7.13.68": - version "7.13.68" - resolved "https://registry.npmjs.org/@microsoft/api-documenter/-/api-documenter-7.13.68.tgz#c1e144764cac0684adefe78fd848d78c3f374681" - integrity sha512-cRjwK1TDyGxFGgCsRG8G0Yi3Z4akvfWgw1pWAxKFbm7ajlQQGZcHPnb+n4lKlSeQ5g/cxc7hcdw54Mvisne9Bg== +"@microsoft/api-documenter@^7.13.77": + version "7.13.77" + resolved "https://registry.npmjs.org/@microsoft/api-documenter/-/api-documenter-7.13.77.tgz#9760b42553679695620b578436ce14c357454e88" + integrity sha512-kot4VJlQUd7i0mFSM7IjyOhF0WWyVrmN9x3sXmd72imgCg9w795QHSkphJ7Qc6ZjhHcolaJvBByEPTKG4exZmA== dependencies: - "@microsoft/api-extractor-model" "7.13.16" + "@microsoft/api-extractor-model" "7.15.1" "@microsoft/tsdoc" "0.13.2" - "@rushstack/node-core-library" "3.43.2" - "@rushstack/ts-command-line" "4.10.4" + "@rushstack/node-core-library" "3.44.2" + "@rushstack/ts-command-line" "4.10.5" colors "~1.2.1" js-yaml "~3.13.1" resolve "~1.17.0" -"@microsoft/api-extractor-model@7.13.16": - version "7.13.16" - resolved "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.13.16.tgz#1d67541ebbcea32672c5fdd9392dc1579b2fc23a" - integrity sha512-ttdxVXsTWL5dd26W1YNLe3LgDsE0EE273aZlcLe58W0opymBybCYU1Mn+OHQM8BuErrdvdN8LdpWAAbkiOEN/Q== +"@microsoft/api-extractor-model@7.15.1", "@microsoft/api-extractor-model@^7.15.1": + version "7.15.1" + resolved "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.15.1.tgz#e52d68676e846d8b86e3b18e2654af39fba6e4a1" + integrity sha512-DWfS1o3oMY0mzdO3OuQbD/9vzn80jwM6tFd7XbiYnkpxwhD83LMGXz7NZWwSh+IaA+9w3LF4w62fT31Qq+dAMw== dependencies: "@microsoft/tsdoc" "0.13.2" "@microsoft/tsdoc-config" "~0.15.2" - "@rushstack/node-core-library" "3.43.2" + "@rushstack/node-core-library" "3.44.2" -"@microsoft/api-extractor-model@7.13.5", "@microsoft/api-extractor-model@^7.13.5": - version "7.13.5" - resolved "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.13.5.tgz#7836a81ba47b9a654062ed0361e4eee69afae51e" - integrity sha512-il6AebNltYo5hEtqXZw4DMvrwBPn6+F58TxwqmsLY+U+sSJNxaYn2jYksArrjErXVPR3gUgRMqD6zsdIkg+WEQ== +"@microsoft/api-extractor@^7.19.2": + version "7.19.2" + resolved "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.19.2.tgz#8c546003523163c1432f6e19506065f790d6182c" + integrity sha512-LxSa9lwp7eYtM4i5y/1n79QpotPKlmpCrVQbkb0LAHE1sCRHpZDTb6p3cMJthDhYPMjAYKOLfq639GwtZrg23Q== dependencies: + "@microsoft/api-extractor-model" "7.15.1" "@microsoft/tsdoc" "0.13.2" "@microsoft/tsdoc-config" "~0.15.2" - "@rushstack/node-core-library" "3.40.0" - -"@microsoft/api-extractor@^7.18.7": - version "7.18.7" - resolved "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.18.7.tgz#851d2413a3c5d696f7cc914eb59de7a7882b2e8b" - integrity sha512-JhtV8LoyLuIecbgCPyZQg08G1kngIRWpai2UzwNil9mGVGYiDZVeeKx8c2phmlPcogmMDm4oQROxyuiYt5sJiw== - dependencies: - "@microsoft/api-extractor-model" "7.13.5" - "@microsoft/tsdoc" "0.13.2" - "@microsoft/tsdoc-config" "~0.15.2" - "@rushstack/node-core-library" "3.40.0" - "@rushstack/rig-package" "0.3.0" - "@rushstack/ts-command-line" "4.9.0" + "@rushstack/node-core-library" "3.44.2" + "@rushstack/rig-package" "0.3.6" + "@rushstack/ts-command-line" "4.10.5" colors "~1.2.1" lodash "~4.17.15" resolve "~1.17.0" semver "~7.3.0" source-map "~0.6.1" - typescript "~4.3.5" + typescript "~4.5.2" "@microsoft/fetch-event-source@2.0.1": version "2.0.1" @@ -5649,25 +5640,10 @@ estree-walker "^2.0.1" picomatch "^2.2.2" -"@rushstack/node-core-library@3.40.0": - version "3.40.0" - resolved "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.40.0.tgz#2551915ea34e34ec2abb7172b9d7f4546144d9d4" - integrity sha512-P6uMPI7cqTdawLSPAG5BQrBu1MHlGRPqecp7ruIRgyukIEzkmh0QAnje4jAL/l1r3hw0qe4e+Dz5ZSnukT/Egg== - dependencies: - "@types/node" "10.17.13" - colors "~1.2.1" - fs-extra "~7.0.1" - import-lazy "~4.0.0" - jju "~1.4.0" - resolve "~1.17.0" - semver "~7.3.0" - timsort "~0.3.0" - z-schema "~3.18.3" - -"@rushstack/node-core-library@3.43.2": - version "3.43.2" - resolved "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.43.2.tgz#f067371a94fd92ed8f9d9aa8201c5e9e17a19f0f" - integrity sha512-b7AEhSf6CvZgvuDcWMFDeKx2mQSn9AVnMQVyxNxFeHCtLz3gJicqCOlw2GOXM8HKh6PInLdil/NVCDcstwSrIw== +"@rushstack/node-core-library@3.44.2": + version "3.44.2" + resolved "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.44.2.tgz#4fcd8f76887ae5968f2796f633a7e48f5ebd2271" + integrity sha512-lQ8Ct267UKkNSJSDxpBWn7SyyITWQ9l3Xqww0V+YY0rMt02r9eiGvwwPaU1ugJW7IMVo6r/HXvgbmpOSPyzGyg== dependencies: "@types/node" "12.20.24" colors "~1.2.1" @@ -5677,30 +5653,20 @@ resolve "~1.17.0" semver "~7.3.0" timsort "~0.3.0" - z-schema "~3.18.3" + z-schema "~5.0.2" -"@rushstack/rig-package@0.3.0": - version "0.3.0" - resolved "https://registry.npmjs.org/@rushstack/rig-package/-/rig-package-0.3.0.tgz#334ad2846797861361b3445d4cc9ae9164b1885c" - integrity sha512-Lj6noF7Q4BBm1hKiBDw94e6uZvq1xlBwM/d2cBFaPqXeGdV+G6r3qaCWfRiSXK0pcHpGGpV5Tb2MdfhVcO6G/g== +"@rushstack/rig-package@0.3.6": + version "0.3.6" + resolved "https://registry.npmjs.org/@rushstack/rig-package/-/rig-package-0.3.6.tgz#a57b53db59106fb93bcda36cad4f8602f508ebc6" + integrity sha512-H/uFsAT6cD4JCYrlQXYMZg+wPVECByFoJLGqfGRiTwSS5ngQw9QxnFV2mPG2LrxFUsMjLQ2lsrYr523700XzfA== dependencies: resolve "~1.17.0" strip-json-comments "~3.1.1" -"@rushstack/ts-command-line@4.10.4": - version "4.10.4" - resolved "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.10.4.tgz#05142b74e5cb207d3dd9b935c82f80d7fcb68042" - integrity sha512-4T5ao4UgDb6LmiRj4GumvG3VT/p6RSMgl7TN7S58ifaAGN2GeTNBajFCDdJs9QQP0d/4tA5p0SFzT7Ps5Byirg== - dependencies: - "@types/argparse" "1.0.38" - argparse "~1.0.9" - colors "~1.2.1" - string-argv "~0.3.1" - -"@rushstack/ts-command-line@4.9.0": - version "4.9.0" - resolved "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.9.0.tgz#781ba42cff73cae097b6d5241b6441e7cc2fe6e0" - integrity sha512-kmT8t+JfnvphISF1C5WwY56RefjwgajhSjs9J4ckvAFXZDXR6F5cvF5/RTh7fGCzIomg8esy2PHO/b52zFoZvA== +"@rushstack/ts-command-line@4.10.5": + version "4.10.5" + resolved "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.10.5.tgz#a31a44ddd24fe3a594e4ad91c22f3ea7668b43a9" + integrity sha512-5fVlTDbKsJ5WyT6L7NrnOlLG3uoITKxoqTPP2j0QZEi95kPbVT4+VPZaXXDJtkrao9qrIyig8pLK9WABY1bb3w== dependencies: "@types/argparse" "1.0.38" argparse "~1.0.9" @@ -7902,16 +7868,16 @@ resolved "https://registry.npmjs.org/@types/node/-/node-16.11.6.tgz#6bef7a2a0ad684cf6e90fcfe31cecabd9ce0a3ae" integrity sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w== -"@types/node@10.17.13", "@types/node@^10.1.0", "@types/node@^10.12.0": - version "10.17.13" - resolved "https://registry.npmjs.org/@types/node/-/node-10.17.13.tgz#ccebcdb990bd6139cd16e84c39dc2fb1023ca90c" - integrity sha512-pMCcqU2zT4TjqYFrWtYHKal7Sl30Ims6ulZ4UFXxI4xbtQqK/qqKwkDoBFCfooRqqmRu9vY3xaJRwxSh673aYg== - "@types/node@12.20.24", "@types/node@^12.7.1": version "12.20.24" resolved "https://registry.npmjs.org/@types/node/-/node-12.20.24.tgz#c37ac69cb2948afb4cef95f424fa0037971a9a5c" integrity sha512-yxDeaQIAJlMav7fH5AQqPH1u8YIuhYJXYBzxaQ4PifsU0GDO38MSdmEDeRlIxrKbC6NbEaaEHDanWb+y30U8SQ== +"@types/node@^10.1.0", "@types/node@^10.12.0": + version "10.17.13" + resolved "https://registry.npmjs.org/@types/node/-/node-10.17.13.tgz#ccebcdb990bd6139cd16e84c39dc2fb1023ca90c" + integrity sha512-pMCcqU2zT4TjqYFrWtYHKal7Sl30Ims6ulZ4UFXxI4xbtQqK/qqKwkDoBFCfooRqqmRu9vY3xaJRwxSh673aYg== + "@types/node@^14.0.10", "@types/node@^14.14.31", "@types/node@^14.14.32": version "14.17.8" resolved "https://registry.npmjs.org/@types/node/-/node-14.17.8.tgz#813b73ab7d82ac06ddfd2458b13c88459a3b319f" @@ -19797,7 +19763,7 @@ lodash.flattendeep@^4.0.0: resolved "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2" integrity sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI= -lodash.get@^4, lodash.get@^4.0.0, lodash.get@^4.4.2: +lodash.get@^4, lodash.get@^4.4.2: version "4.4.2" resolved "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk= @@ -19832,7 +19798,7 @@ lodash.isempty@^4.4.0: resolved "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz#6f86cbedd8be4ec987be9aaf33c9684db1b31e7e" integrity sha1-b4bL7di+TsmHvpqvM8loTbGzHn4= -lodash.isequal@^4.0.0: +lodash.isequal@^4.5.0: version "4.5.0" resolved "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA= @@ -28427,6 +28393,11 @@ typescript@~4.3.5: resolved "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4" integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA== +typescript@~4.5.2: + version "4.5.4" + resolved "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz#a17d3a0263bf5c8723b9c52f43c5084edf13c2e8" + integrity sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg== + ua-parser-js@^0.7.18: version "0.7.28" resolved "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.28.tgz#8ba04e653f35ce210239c64661685bf9121dec31" @@ -29114,10 +29085,10 @@ validate.io-number@^1.0.3: resolved "https://registry.npmjs.org/validate.io-number/-/validate.io-number-1.0.3.tgz#f63ffeda248bf28a67a8d48e0e3b461a1665baf8" integrity sha1-9j/+2iSL8opnqNSODjtGGhZluvg= -validator@^8.0.0: - version "8.2.0" - resolved "https://registry.npmjs.org/validator/-/validator-8.2.0.tgz#3c1237290e37092355344fef78c231249dab77b9" - integrity sha512-Yw5wW34fSv5spzTXNkokD6S6/Oq92d8q/t14TqsS3fAiA1RYnxSFSIZ+CY3n6PGGRCq5HhJTSepQvFUS2QUDxA== +validator@^13.7.0: + version "13.7.0" + resolved "https://registry.npmjs.org/validator/-/validator-13.7.0.tgz#4f9658ba13ba8f3d82ee881d3516489ea85c0857" + integrity sha512-nYXQLCBkpJ8X6ltALua9dRrZDHVYxjJ1wgskNt1lH9fzGjs3tgojGSCBjmEPwkWS1y29+DrizMTW19Pr9uB2nw== value-or-promise@1.0.11: version "1.0.11" @@ -30156,14 +30127,14 @@ yup@^0.32.9: property-expr "^2.0.4" toposort "^2.0.2" -z-schema@~3.18.3: - version "3.18.4" - resolved "https://registry.npmjs.org/z-schema/-/z-schema-3.18.4.tgz#ea8132b279533ee60be2485a02f7e3e42541a9a2" - integrity sha512-DUOKC/IhbkdLKKiV89gw9DUauTV8U/8yJl1sjf6MtDmzevLKOF2duNJ495S3MFVjqZarr+qNGCPbkg4mu4PpLw== +z-schema@~5.0.2: + version "5.0.2" + resolved "https://registry.npmjs.org/z-schema/-/z-schema-5.0.2.tgz#f410394b2c9fcb9edaf6a7511491c0bb4e89a504" + integrity sha512-40TH47ukMHq5HrzkeVE40Ad7eIDKaRV2b+Qpi2prLc9X9eFJFzV7tMe5aH12e6avaSS/u5l653EQOv+J9PirPw== dependencies: - lodash.get "^4.0.0" - lodash.isequal "^4.0.0" - validator "^8.0.0" + lodash.get "^4.4.2" + lodash.isequal "^4.5.0" + validator "^13.7.0" optionalDependencies: commander "^2.7.1" From 7b6b992e7ac40be54cd299921120b07e287deff0 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 15 Dec 2021 01:40:04 +0100 Subject: [PATCH 39/41] scripts/api-extractor: remove workaround for duplicate install Signed-off-by: Patrik Oldsberg --- scripts/api-extractor.ts | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/scripts/api-extractor.ts b/scripts/api-extractor.ts index 8ca7743cf2..22eae267ee 100644 --- a/scripts/api-extractor.ts +++ b/scripts/api-extractor.ts @@ -35,7 +35,6 @@ import { import { Program } from 'typescript'; import { DocNode, - DocSection, IDocNodeContainerParameters, TSDocTagSyntaxKind, } from '@microsoft/tsdoc'; @@ -51,7 +50,6 @@ import { DocHeading } from '@microsoft/api-documenter/lib/nodes/DocHeading'; import { CustomMarkdownEmitter } from '@microsoft/api-documenter/lib/markdown/CustomMarkdownEmitter'; import { IMarkdownEmitterContext } from '@microsoft/api-documenter/lib/markdown/MarkdownEmitter'; import { AstDeclaration } from '@microsoft/api-extractor/lib/analyzer/AstDeclaration'; -import { DocTableCell } from '@microsoft/api-documenter/lib/nodes/DocTableCell'; const tmpDir = resolvePath(__dirname, '../node_modules/.cache/api-extractor'); @@ -605,18 +603,9 @@ async function buildDocs({ }); for (const apiMember of apiModel.members) { - // This is a workaround for this check failing: https://github.com/microsoft/rushstack/blob/915aca8d8847b65981892f44f0544ccb00752792/apps/api-documenter/src/documenters/MarkdownDocumenter.ts#L991 - const description = new DocSection({ configuration }); - if (apiMember.tsdocComment !== undefined) { - this._appendAndMergeSection( - description, - apiMember.tsdocComment.summarySection, - ); - } - const row = new DocTableRow({ configuration }, [ this._createTitleCell(apiMember), - new DocTableCell({ configuration }, description.nodes), + this._createDescriptionCell(apiMember), ]); if (apiMember.kind === 'Package') { From 0c09c969c7c4ca8b577620fc22dddd734de29441 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Dec 2021 04:12:30 +0000 Subject: [PATCH 40/41] build(deps-dev): bump @types/dagre from 0.7.44 to 0.7.46 Bumps [@types/dagre](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/dagre) from 0.7.44 to 0.7.46. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/dagre) --- updated-dependencies: - dependency-name: "@types/dagre" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 0a47ca410c..d8c198afc6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7327,9 +7327,9 @@ "@types/d3-selection" "*" "@types/dagre@^0.7.44": - version "0.7.44" - resolved "https://registry.npmjs.org/@types/dagre/-/dagre-0.7.44.tgz#8f4b796b118ca29c132da7068fbc0d0351ee5851" - integrity sha512-N6HD+79w77ZVAaVO7JJDW5yJ9LAxM62FpgNGO9xEde+KVYjDRyhIMzfiErXpr1g0JPon9kwlBzoBK6s4fOww9Q== + version "0.7.46" + resolved "https://registry.npmjs.org/@types/dagre/-/dagre-0.7.46.tgz#c51ffcc62ca8a9affa07f5e06842acd840d3d442" + integrity sha512-ku3y+F8sPqmiB5Ugl22NpukI2dLAViJiWwdtueXLeuF4fxZozl+bytPSFVlLu/gDgaKiwobu3LBXXRWktIMiIA== "@types/debug@^4.0.0": version "4.1.7" From 95284ba57210aed75cf223bf96fc1bacc8b35e04 Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Wed, 15 Dec 2021 09:45:15 +0100 Subject: [PATCH 41/41] improved tests / comment Signed-off-by: Jan Vilimek --- .../src/components/Cards/OwnershipCard/OwnershipCard.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx index c4710c14ab..439365e583 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx @@ -115,7 +115,7 @@ const getEntitiesMock = ( const filterKinds = !Array.isArray(request?.filter) && Array.isArray(request?.filter?.kind) ? request?.filter?.kind ?? [] - : []; // we expect the request to be like { filter: { kind: ['API','System'], .... } + : []; // we expect the request to be like { filter: { kind: ['API','System'], .... }. If changed in OwnerShipCard, let's change in also here return Promise.resolve({ items: items.filter(item => filterKinds.find(k => k === item.kind)), } as CatalogListResponse);