@backstage-community/plugin-multi-source-security-viewer 0.1.2 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @backstage-community/plugin-multi-source-security-viewer
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 262f9d9: Updated dependency `@backstage-community/plugin-github-actions` to `^0.9.0`.
8
+
9
+ ## 0.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 764e6f3: Support Azure pipelines
14
+
3
15
  ## 0.1.2
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -14,6 +14,7 @@ This plugin enables you to visualize pipeline security information from multiple
14
14
  - [Jenkins](../../../jenkins/plugins/jenkins-backend/README.md)
15
15
  - [Github Actions](../../../github-actions/plugins/github-actions/README.md)
16
16
  - [Gitlab CI](https://github.com/immobiliare/backstage-plugin-gitlab?tab=readme-ov-file#setup)
17
+ - [Azure Pipelines](../../../azure-devops/plugins/azure-devops/README.md)
17
18
 
18
19
  #### Procedure
19
20
 
@@ -0,0 +1,88 @@
1
+ import { createApiRef } from '@backstage/core-plugin-api';
2
+ import { getAnnotationValuesFromEntity } from '@backstage-community/plugin-azure-devops';
3
+ import { BuildStatus, BuildResult } from '@backstage-community/plugin-azure-devops-common';
4
+ import { stringifyEntityRef } from '@backstage/catalog-model';
5
+ import { PipelineRunResult } from '../models/pipelineRunResult.esm.js';
6
+ import { RunStatus } from '../types/pipelinerun.esm.js';
7
+
8
+ const mssvAzureDevopsApiRef = createApiRef({
9
+ id: "plugin.mssv-api-azuredevops.service"
10
+ });
11
+ const mapStatus = (status) => {
12
+ const AzureDevopsRunStatus = { ...BuildStatus, ...BuildResult };
13
+ const runStatus = AzureDevopsRunStatus[status];
14
+ switch (runStatus) {
15
+ case BuildResult.Succeeded:
16
+ return RunStatus.Succeeded;
17
+ case BuildResult.Failed:
18
+ return RunStatus.Failed;
19
+ case BuildResult.Canceled:
20
+ return RunStatus.Cancelled;
21
+ case BuildStatus.InProgress:
22
+ return RunStatus.Running;
23
+ default:
24
+ return RunStatus.Unknown;
25
+ }
26
+ };
27
+ class MssvAzureDevopsClient {
28
+ azureDevopsApi;
29
+ constructor(options) {
30
+ this.azureDevopsApi = options.azureDevopsApi;
31
+ }
32
+ async getPipelineSummary(options) {
33
+ const { entity, page, pageSize } = options;
34
+ const { project, repo, definition, host, org } = getAnnotationValuesFromEntity(entity);
35
+ const [sliceStart, sliceEnd] = [
36
+ page * pageSize,
37
+ page * pageSize + pageSize
38
+ ];
39
+ const buildRuns = await this.azureDevopsApi.getBuildRuns(
40
+ project,
41
+ stringifyEntityRef(entity),
42
+ repo,
43
+ definition,
44
+ host,
45
+ org
46
+ ) ?? { items: [] };
47
+ const buildRunsSlice = buildRuns.items.slice(sliceStart, sliceEnd);
48
+ const buildRunsWithLogs = await Promise.all(
49
+ buildRunsSlice.map(async (run) => {
50
+ if (!run?.id) {
51
+ return void 0;
52
+ }
53
+ const logs = await this.azureDevopsApi.getBuildRunLog(
54
+ project,
55
+ stringifyEntityRef(entity),
56
+ run.id,
57
+ host,
58
+ org
59
+ ).then((res) => res?.log.join(" \n")).catch(() => "");
60
+ const status = mapStatus(run?.result ?? run?.status ?? "Unknown");
61
+ return {
62
+ run,
63
+ logs,
64
+ status
65
+ };
66
+ }).filter(Boolean)
67
+ // remove undefined values
68
+ );
69
+ const results = buildRunsWithLogs.map(
70
+ (pr) => new PipelineRunResult({
71
+ id: pr?.run?.id?.toString(),
72
+ displayName: pr?.run?.title,
73
+ status: pr?.status,
74
+ logs: pr?.logs
75
+ })
76
+ ) || [];
77
+ return {
78
+ results,
79
+ totalCount: buildRuns.items.length
80
+ };
81
+ }
82
+ async getPipelineDetail() {
83
+ return { results: [], totalCount: 0 };
84
+ }
85
+ }
86
+
87
+ export { MssvAzureDevopsClient, mssvAzureDevopsApiRef };
88
+ //# sourceMappingURL=azure.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azure.esm.js","sources":["../../src/api/azure.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport {\n AzureDevOpsApi,\n getAnnotationValuesFromEntity,\n} from '@backstage-community/plugin-azure-devops';\nimport {\n BuildResult,\n BuildStatus,\n} from '@backstage-community/plugin-azure-devops-common';\nimport { MssvApi, MssvApiResponse } from './mssv';\nimport { Entity, stringifyEntityRef } from '@backstage/catalog-model';\nimport { PipelineRunResult } from '../models/pipelineRunResult';\nimport { RunStatus } from '../types/pipelinerun';\n\n// Apiref to map with client\nexport const mssvAzureDevopsApiRef = createApiRef<MssvApi>({\n id: 'plugin.mssv-api-azuredevops.service',\n});\n\nconst mapStatus = (status: string | BuildResult | BuildStatus): RunStatus => {\n const AzureDevopsRunStatus = { ...BuildStatus, ...BuildResult };\n const runStatus =\n AzureDevopsRunStatus[status as keyof typeof AzureDevopsRunStatus];\n switch (runStatus) {\n case BuildResult.Succeeded:\n return RunStatus.Succeeded;\n case BuildResult.Failed:\n return RunStatus.Failed;\n case BuildResult.Canceled:\n return RunStatus.Cancelled;\n case BuildStatus.InProgress:\n return RunStatus.Running;\n default:\n return RunStatus.Unknown;\n }\n};\n\nexport class MssvAzureDevopsClient implements MssvApi {\n private readonly azureDevopsApi: AzureDevOpsApi;\n\n constructor(options: { azureDevopsApi: AzureDevOpsApi }) {\n this.azureDevopsApi = options.azureDevopsApi;\n }\n\n async getPipelineSummary(options: {\n entity: Entity;\n page: number;\n pageSize: number;\n }): Promise<MssvApiResponse> {\n const { entity, page, pageSize } = options;\n const { project, repo, definition, host, org } =\n getAnnotationValuesFromEntity(entity);\n\n const [sliceStart, sliceEnd] = [\n page * pageSize,\n page * pageSize + pageSize,\n ];\n\n const buildRuns = (await this.azureDevopsApi.getBuildRuns(\n project,\n stringifyEntityRef(entity),\n repo,\n definition,\n host,\n org,\n )) ?? { items: [] };\n\n const buildRunsSlice = buildRuns.items.slice(sliceStart, sliceEnd);\n const buildRunsWithLogs = await Promise.all(\n buildRunsSlice\n .map(async run => {\n if (!run?.id) {\n return undefined;\n }\n\n const logs = await this.azureDevopsApi\n .getBuildRunLog(\n project,\n stringifyEntityRef(entity),\n run.id,\n host,\n org,\n )\n .then(res => res?.log.join(' \\n'))\n .catch(() => ''); // fallback on empty string. It disables logs button and updates tooltip\n\n const status = mapStatus(run?.result ?? run?.status ?? 'Unknown');\n\n return {\n run,\n logs,\n status,\n };\n })\n .filter(Boolean), // remove undefined values\n );\n\n const results =\n buildRunsWithLogs.map(\n pr =>\n new PipelineRunResult({\n id: pr?.run?.id?.toString(),\n displayName: pr?.run?.title,\n status: pr?.status,\n logs: pr?.logs,\n }),\n ) || [];\n\n return {\n results,\n totalCount: buildRuns.items.length,\n };\n }\n\n async getPipelineDetail(): Promise<MssvApiResponse> {\n return { results: [], totalCount: 0 };\n }\n}\n"],"names":[],"mappings":";;;;;;;AA8BO,MAAM,wBAAwB,YAAsB,CAAA;AAAA,EACzD,EAAI,EAAA;AACN,CAAC;AAED,MAAM,SAAA,GAAY,CAAC,MAA0D,KAAA;AAC3E,EAAA,MAAM,oBAAuB,GAAA,EAAE,GAAG,WAAA,EAAa,GAAG,WAAY,EAAA;AAC9D,EAAM,MAAA,SAAA,GACJ,qBAAqB,MAA2C,CAAA;AAClE,EAAA,QAAQ,SAAW;AAAA,IACjB,KAAK,WAAY,CAAA,SAAA;AACf,MAAA,OAAO,SAAU,CAAA,SAAA;AAAA,IACnB,KAAK,WAAY,C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AGT,QAAM,MAAA,IAAA,GAAO,MAAM,IAAA,CAAK,cACrB,CAAA,cAAA;AAAA,UACC,OAAA;AAAA,UACA,mBAAmB,MAAM,CAAA;AAAA,UACzB,GAAI,CAAA,EAAA;AAAA,UACJ,IAAA;AAAA,UACA;AAAA,SACF,CACC,IAAK,CAAA,CAAA,GAAA,KAAO,GAAK,EAAA,GAAA,CAAI,IAAK,CAAA,KAAK,CAAC,CAAA,CAChC,KAAM,CAAA,MAAM,EAAE,CAAA;AAEjB,QAAA,MAAM,SAAS,SAAU,CAAA,GAAA,EAAK,MAAU,IAAA,GAAA,EAAK,UAAU,SAAS,CAAA;AAEhE,QAAO,OAAA;AAAA,UACL,GAAA;AAAA,UACA,IAAA;AAAA,UACA;AAAA,SACF;AAAA,OACD,CACA,CAAA,MAAA,CAAO,OAAO;AAAA;AAAA,KACnB;AAEA,IAAA,MAAM,UACJ,iBAAkB,CAAA,GAAA;AAAA,MAChB,CAAA,EAAA,KACE,IAAI,iBAAkB,CAAA;AAAA,QACpB,EAAI,EAAA,EAAA,EAAI,GAAK,EAAA,EAAA,EAAI,QAAS,EAAA;AAAA,QAC1B,WAAA,EAAa,IAAI,GAAK,EAAA,KAAA;AAAA,QACtB,QAAQ,EAAI,EAAA,MAAA;AAAA,QACZ,MAAM,EAAI,EAAA;AAAA,OACX;AAAA,SACA,EAAC;AAER,IAAO,OAAA;AAAA,MACL,OAAA;AAAA,MACA,UAAA,EAAY,UAAU,KAAM,CAAA;AAAA,KAC9B;AAAA;AACF,EAEA,MAAM,iBAA8C,GAAA;AAClD,IAAA,OAAO,EAAE,OAAA,EAAS,EAAC,EAAG,YAAY,CAAE,EAAA;AAAA;AAExC;;;;"}
@@ -9,6 +9,8 @@ import { isGithubActionsAvailable } from '@backstage-community/plugin-github-act
9
9
  import { mssvGitlabCIApiRef } from '../api/gitlab.esm.js';
10
10
  import { isGitlabAvailable } from '@immobiliarelabs/backstage-plugin-gitlab';
11
11
  import { SecurityViewerMultiCIPipelines } from './SecurityViewer/SecurityViewerMultiCIPipelines.esm.js';
12
+ import { mssvAzureDevopsApiRef } from '../api/azure.esm.js';
13
+ import { isAzurePipelinesAvailable } from '@backstage-community/plugin-azure-devops';
12
14
 
13
15
  const AVAILABLE_APIS = [
14
16
  {
@@ -25,6 +27,11 @@ const AVAILABLE_APIS = [
25
27
  title: "Gitlab CI",
26
28
  apiRef: mssvGitlabCIApiRef,
27
29
  availabilityCallback: isGitlabAvailable
30
+ },
31
+ {
32
+ title: "Azure Pipelines",
33
+ apiRef: mssvAzureDevopsApiRef,
34
+ availabilityCallback: isAzurePipelinesAvailable
28
35
  }
29
36
  ];
30
37
  const Router = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"Router.esm.js","sources":["../../src/components/Router.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { Route, Routes } from 'react-router-dom';\nimport { githubActionsJobRouteRef, jenkinsJobRunRouteRef } from '../routes';\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport { ApiRef } from '@backstage/core-plugin-api/index';\nimport { Entity } from '@backstage/catalog-model';\nimport { mssvJenkinsApiRef } from '../api/jenkins';\nimport { isJenkinsAvailable } from '@backstage-community/plugin-jenkins';\nimport { mssvGithubActionsApiRef } from '../api/github';\nimport { isGithubActionsAvailable } from '@backstage-community/plugin-github-actions';\nimport { mssvGitlabCIApiRef } from '../api/gitlab';\nimport { isGitlabAvailable } from '@immobiliarelabs/backstage-plugin-gitlab';\nimport { MultiCIConfig } from '../types/multiCI';\nimport { SecurityViewerMultiCIPipelines } from './SecurityViewer/SecurityViewerMultiCIPipelines';\n\ntype ApiItem = {\n title: string;\n apiRef: ApiRef<any>;\n availabilityCallback: (entity: Entity) => boolean;\n};\n\nconst AVAILABLE_APIS: ApiItem[] = [\n {\n title: 'Jenkins',\n apiRef: mssvJenkinsApiRef,\n availabilityCallback: isJenkinsAvailable,\n },\n {\n title: 'Github Actions',\n apiRef: mssvGithubActionsApiRef,\n availabilityCallback: isGithubActionsAvailable,\n },\n {\n title: 'Gitlab CI',\n apiRef: mssvGitlabCIApiRef,\n availabilityCallback: isGitlabAvailable,\n },\n];\n\nexport const Router = () => {\n const { entity } = useEntity();\n const multiCIConfig = AVAILABLE_APIS.reduce((acc, api: ApiItem) => {\n if (api.availabilityCallback(entity)) {\n acc.push({ title: api.title, apiRef: api.apiRef });\n }\n return acc;\n }, [] as MultiCIConfig[]);\n\n return (\n <Routes>\n <Route\n path=\"/\"\n element={\n <SecurityViewerMultiCIPipelines multiCIConfig={multiCIConfig} />\n }\n />\n <Route\n path={`${jenkinsJobRunRouteRef.path}`}\n element={\n <SecurityViewerMultiCIPipelines\n multiCIConfig={multiCIConfig}\n isJenkinsDetail\n />\n }\n />\n <Route\n path={`${githubActionsJobRouteRef.path}`}\n element={\n <SecurityViewerMultiCIPipelines\n multiCIConfig={multiCIConfig}\n isGithubActionsDetail\n />\n }\n />\n </Routes>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAoCA,MAAM,cAA4B,GAAA;AAAA,EAChC;AAAA,IACE,KAAO,EAAA,SAAA;AAAA,IACP,MAAQ,EAAA,iBAAA;AAAA,IACR,oBAAsB,EAAA;AAAA,GACxB;AAAA,EACA;AAAA,IACE,KAAO,EAAA,gBAAA;AAAA,IACP,MAAQ,EAAA,uBAAA;AAAA,IACR,oBAAsB,EAAA;AAAA,GACxB;AAAA,EACA;AAAA,IACE,KAAO,EAAA,WAAA;AAAA,IACP,MAAQ,EAAA,kBAAA;AAAA,IACR,oBAAsB,EAAA;AAAA;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"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { Route, Routes } from 'react-router-dom';\nimport { githubActionsJobRouteRef, jenkinsJobRunRouteRef } from '../routes';\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport { ApiRef } from '@backstage/core-plugin-api/index';\nimport { Entity } from '@backstage/catalog-model';\nimport { mssvJenkinsApiRef } from '../api/jenkins';\nimport { isJenkinsAvailable } from '@backstage-community/plugin-jenkins';\nimport { mssvGithubActionsApiRef } from '../api/github';\nimport { isGithubActionsAvailable } from '@backstage-community/plugin-github-actions';\nimport { mssvGitlabCIApiRef } from '../api/gitlab';\nimport { isGitlabAvailable } from '@immobiliarelabs/backstage-plugin-gitlab';\nimport { MultiCIConfig } from '../types/multiCI';\nimport { SecurityViewerMultiCIPipelines } from './SecurityViewer/SecurityViewerMultiCIPipelines';\nimport { mssvAzureDevopsApiRef } from '../api/azure';\nimport { isAzurePipelinesAvailable } from '@backstage-community/plugin-azure-devops';\n\ntype ApiItem = {\n title: string;\n apiRef: ApiRef<any>;\n availabilityCallback: (entity: Entity) => boolean;\n};\n\nconst AVAILABLE_APIS: ApiItem[] = [\n {\n title: 'Jenkins',\n apiRef: mssvJenkinsApiRef,\n availabilityCallback: isJenkinsAvailable,\n },\n {\n title: 'Github Actions',\n apiRef: mssvGithubActionsApiRef,\n availabilityCallback: isGithubActionsAvailable,\n },\n {\n title: 'Gitlab CI',\n apiRef: mssvGitlabCIApiRef,\n availabilityCallback: isGitlabAvailable,\n },\n {\n title: 'Azure Pipelines',\n apiRef: mssvAzureDevopsApiRef,\n availabilityCallback: isAzurePipelinesAvailable,\n },\n];\n\nexport const Router = () => {\n const { entity } = useEntity();\n const multiCIConfig = AVAILABLE_APIS.reduce((acc, api: ApiItem) => {\n if (api.availabilityCallback(entity)) {\n acc.push({ title: api.title, apiRef: api.apiRef });\n }\n return acc;\n }, [] as MultiCIConfig[]);\n\n return (\n <Routes>\n <Route\n path=\"/\"\n element={\n <SecurityViewerMultiCIPipelines multiCIConfig={multiCIConfig} />\n }\n />\n <Route\n path={`${jenkinsJobRunRouteRef.path}`}\n element={\n <SecurityViewerMultiCIPipelines\n multiCIConfig={multiCIConfig}\n isJenkinsDetail\n />\n }\n />\n <Route\n path={`${githubActionsJobRouteRef.path}`}\n element={\n <SecurityViewerMultiCIPipelines\n multiCIConfig={multiCIConfig}\n isGithubActionsDetail\n />\n }\n />\n </Routes>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAsCA,MAAM,cAA4B,GAAA;AAAA,EAChC;AAAA,IACE,KAAO,EAAA,SAAA;AAAA,IACP,MAAQ,EAAA,iBAAA;AAAA,IACR,oBAAsB,EAAA;AAAA,GACxB;AAAA,EACA;AAAA,IACE,KAAO,EAAA,gBAAA;AAAA,IACP,MAAQ,EAAA,uBAAA;AAAA,IACR,oBAAsB,EAAA;AAAA,GACxB;AAAA,EACA;AAAA,IACE,KAAO,EAAA,WAAA;AAAA,IACP,MAAQ,EAAA,kBAAA;AAAA,IACR,oBAAsB,EAAA;AAAA,GACxB;AAAA,EACA;AAAA,IACE,KAAO,EAAA,iBAAA;AAAA,IACP,MAAQ,EAAA,qBAAA;AAAA,IACR,oBAAsB,EAAA;AAAA;AAE1B,CAAA;AAEO,MAAM,SAAS,MAAM;AAC1B,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA;AAC7B,EAAA,MAAM,aAAgB,GAAA,cAAA,CAAe,MAAO,CAAA,CAAC,KAAK,GAAiB,KAAA;AACjE,IAAI,IAAA,GAAA,CAAI,oBAAqB,CAAA,MAAM,CAAG,EAAA;AACpC,MAAI,GAAA,CAAA,IAAA,CAAK,EAAE,KAAO,EAAA,GAAA,CAAI,OAAO,MAAQ,EAAA,GAAA,CAAI,QAAQ,CAAA;AAAA;AAEnD,IAAO,OAAA,GAAA;AAAA,GACT,EAAG,EAAqB,CAAA;AAExB,EAAA,2CACG,MACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,IAAK,EAAA,GAAA;AAAA,MACL,OAAA,kBACG,KAAA,CAAA,aAAA,CAAA,8BAAA,EAAA,EAA+B,aAA8B,EAAA;AAAA;AAAA,GAGlE,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAM,CAAG,EAAA,qBAAA,CAAsB,IAAI,CAAA,CAAA;AAAA,MACnC,OACE,kBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,8BAAA;AAAA,QAAA;AAAA,UACC,aAAA;AAAA,UACA,eAAe,EAAA;AAAA;AAAA;AACjB;AAAA,GAGJ,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAM,CAAG,EAAA,wBAAA,CAAyB,IAAI,CAAA,CAAA;AAAA,MACtC,OACE,kBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,8BAAA;AAAA,QAAA;AAAA,UACC,aAAA;AAAA,UACA,qBAAqB,EAAA;AAAA;AAAA;AACvB;AAAA,GAGN,CAAA;AAEJ;;;;"}
@@ -9,6 +9,8 @@ import { GithubActionsClient, isGithubActionsAvailable } from '@backstage-commun
9
9
  import { scmAuthApiRef } from '@backstage/integration-react';
10
10
  import { mssvGitlabCIApiRef, MssvGitlabCIClient, CustomGitlabCiClient } from './api/gitlab.esm.js';
11
11
  import { isGitlabAvailable } from '@immobiliarelabs/backstage-plugin-gitlab';
12
+ import { AzureDevOpsClient, isAzurePipelinesAvailable } from '@backstage-community/plugin-azure-devops';
13
+ import { mssvAzureDevopsApiRef, MssvAzureDevopsClient } from './api/azure.esm.js';
12
14
 
13
15
  const multiSourceSecurityViewerPlugin = createPlugin({
14
16
  id: "multi-source-security-viewer",
@@ -62,13 +64,28 @@ const multiSourceSecurityViewerPlugin = createPlugin({
62
64
  })
63
65
  });
64
66
  }
67
+ }),
68
+ createApiFactory({
69
+ api: mssvAzureDevopsApiRef,
70
+ deps: {
71
+ discoveryApi: discoveryApiRef,
72
+ fetchApi: fetchApiRef
73
+ },
74
+ factory: ({ discoveryApi, fetchApi }) => {
75
+ return new MssvAzureDevopsClient({
76
+ azureDevopsApi: new AzureDevOpsClient({
77
+ discoveryApi,
78
+ fetchApi
79
+ })
80
+ });
81
+ }
65
82
  })
66
83
  ],
67
84
  routes: {
68
85
  entityContent: rootRouteRef
69
86
  }
70
87
  });
71
- const isMultiCIAvailable = (entity) => isJenkinsAvailable(entity) || isGitlabAvailable(entity) || isGithubActionsAvailable(entity);
88
+ const isMultiCIAvailable = (entity) => isJenkinsAvailable(entity) || isGitlabAvailable(entity) || isGithubActionsAvailable(entity) || isAzurePipelinesAvailable(entity);
72
89
  const EntityMultiCIPipelinesContent = multiSourceSecurityViewerPlugin.provide(
73
90
  createRoutableExtension({
74
91
  name: "EntityMultiCIPipelinesContent",
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.esm.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport '@patternfly/react-core/dist/styles/base-no-reset.css';\nimport '@patternfly/patternfly/patternfly.css';\n\nimport {\n configApiRef,\n createApiFactory,\n createPlugin,\n discoveryApiRef,\n fetchApiRef,\n identityApiRef,\n gitlabAuthApiRef,\n createRoutableExtension,\n} from '@backstage/core-plugin-api';\n\nimport { rootRouteRef } from './routes';\nimport { MssvJenkinsClient, mssvJenkinsApiRef } from './api/jenkins';\nimport {\n JenkinsClient,\n isJenkinsAvailable,\n} from '@backstage-community/plugin-jenkins';\nimport { MssvGithubActionsClient, mssvGithubActionsApiRef } from './api/github';\nimport {\n GithubActionsClient,\n isGithubActionsAvailable,\n} from '@backstage-community/plugin-github-actions';\nimport { scmAuthApiRef } from '@backstage/integration-react';\nimport {\n CustomGitlabCiClient,\n MssvGitlabCIClient,\n mssvGitlabCIApiRef,\n} from './api/gitlab';\nimport { isGitlabAvailable } from '@immobiliarelabs/backstage-plugin-gitlab';\nimport { Entity } from '@backstage/catalog-model';\n\n/** @public */\nexport const multiSourceSecurityViewerPlugin = createPlugin({\n id: 'multi-source-security-viewer',\n apis: [\n createApiFactory({\n api: mssvJenkinsApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n fetchApi: fetchApiRef,\n },\n factory: ({ discoveryApi, fetchApi }) => {\n return new MssvJenkinsClient({\n jenkinsApi: new JenkinsClient({\n discoveryApi,\n fetchApi,\n }),\n });\n },\n }),\n createApiFactory({\n api: mssvGithubActionsApiRef,\n deps: {\n configApi: configApiRef,\n scmAuthApi: scmAuthApiRef,\n },\n factory: ({ configApi, scmAuthApi }) => {\n return new MssvGithubActionsClient({\n githubActionsApi: new GithubActionsClient({ configApi, scmAuthApi }),\n });\n },\n }),\n createApiFactory({\n api: mssvGitlabCIApiRef,\n deps: {\n configApi: configApiRef,\n discoveryApi: discoveryApiRef,\n gitlabAuthApi: gitlabAuthApiRef,\n identityApi: identityApiRef,\n },\n factory: ({ configApi, identityApi, discoveryApi, gitlabAuthApi }) => {\n return new MssvGitlabCIClient({\n gitlabCiApi: new CustomGitlabCiClient({\n discoveryApi,\n gitlabAuthApi,\n identityApi,\n codeOwnersPath: configApi.getOptionalString(\n 'gitlab.defaultCodeOwnersPath',\n ),\n readmePath: configApi.getOptionalString('gitlab.defaultReadmePath'),\n useOAuth: configApi.getOptionalBoolean('gitlab.useOAuth'),\n }),\n });\n },\n }),\n ],\n routes: {\n entityContent: rootRouteRef,\n },\n});\n\n/** @public */\nexport const isMultiCIAvailable = (entity: Entity): boolean =>\n isJenkinsAvailable(entity) ||\n isGitlabAvailable(entity) ||\n isGithubActionsAvailable(entity);\n\n/** @public */\nexport const EntityMultiCIPipelinesContent =\n multiSourceSecurityViewerPlugin.provide(\n createRoutableExtension({\n name: 'EntityMultiCIPipelinesContent',\n component: () => import('./components/Router').then(m => m.Router),\n mountPoint: rootRouteRef,\n }),\n );\n"],"names":[],"mappings":";;;;;;;;;;;;AAkDO,MAAM,kCAAkC,YAAa,CAAA;AAAA,EAC1D,EAAI,EAAA,8BAAA;AAAA,EACJ,IAAM,EAAA;AAAA,IACJ,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,iBAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,YAAc,EAAA,eAAA;AAAA,QACd,QAAU,EAAA;AAAA,OACZ;AAAA,MACA,OAAS,EAAA,CAAC,EAAE,YAAA,EAAc,UAAe,KAAA;AACvC,QAAA,OAAO,IAAI,iBAAkB,CAAA;AAAA,UAC3B,UAAA,EAAY,IAAI,aAAc,CAAA;AAAA,YAC5B,YAAA;AAAA,YACA;AAAA,WACD;AAAA,SACF,CAAA;AAAA;AACH,KACD,CAAA;AAAA,IACD,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,uBAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,SAAW,EAAA,YAAA;AAAA,QACX,UAAY,EAAA;AAAA,OACd;AAAA,MACA,OAAS,EAAA,CAAC,EAAE,SAAA,EAAW,YAAiB,KAAA;AACtC,QAAA,OAAO,IAAI,uBAAwB,CAAA;AAAA,UACjC,kBAAkB,IAAI,mBAAA,C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ors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport '@patternfly/react-core/dist/styles/base-no-reset.css';\nimport '@patternfly/patternfly/patternfly.css';\n\nimport {\n configApiRef,\n createApiFactory,\n createPlugin,\n discoveryApiRef,\n fetchApiRef,\n identityApiRef,\n gitlabAuthApiRef,\n createRoutableExtension,\n} from '@backstage/core-plugin-api';\n\nimport { rootRouteRef } from './routes';\nimport { MssvJenkinsClient, mssvJenkinsApiRef } from './api/jenkins';\nimport {\n JenkinsClient,\n isJenkinsAvailable,\n} from '@backstage-community/plugin-jenkins';\nimport { MssvGithubActionsClient, mssvGithubActionsApiRef } from './api/github';\nimport {\n GithubActionsClient,\n isGithubActionsAvailable,\n} from '@backstage-community/plugin-github-actions';\nimport { scmAuthApiRef } from '@backstage/integration-react';\nimport {\n CustomGitlabCiClient,\n MssvGitlabCIClient,\n mssvGitlabCIApiRef,\n} from './api/gitlab';\nimport { isGitlabAvailable } from '@immobiliarelabs/backstage-plugin-gitlab';\nimport { Entity } from '@backstage/catalog-model';\nimport {\n AzureDevOpsClient,\n isAzurePipelinesAvailable,\n} from '@backstage-community/plugin-azure-devops';\nimport { MssvAzureDevopsClient, mssvAzureDevopsApiRef } from './api/azure';\n\n/** @public */\nexport const multiSourceSecurityViewerPlugin = createPlugin({\n id: 'multi-source-security-viewer',\n apis: [\n createApiFactory({\n api: mssvJenkinsApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n fetchApi: fetchApiRef,\n },\n factory: ({ discoveryApi, fetchApi }) => {\n return new MssvJenkinsClient({\n jenkinsApi: new JenkinsClient({\n discoveryApi,\n fetchApi,\n }),\n });\n },\n }),\n createApiFactory({\n api: mssvGithubActionsApiRef,\n deps: {\n configApi: configApiRef,\n scmAuthApi: scmAuthApiRef,\n },\n factory: ({ configApi, scmAuthApi }) => {\n return new MssvGithubActionsClient({\n githubActionsApi: new GithubActionsClient({ configApi, scmAuthApi }),\n });\n },\n }),\n createApiFactory({\n api: mssvGitlabCIApiRef,\n deps: {\n configApi: configApiRef,\n discoveryApi: discoveryApiRef,\n gitlabAuthApi: gitlabAuthApiRef,\n identityApi: identityApiRef,\n },\n factory: ({ configApi, identityApi, discoveryApi, gitlabAuthApi }) => {\n return new MssvGitlabCIClient({\n gitlabCiApi: new CustomGitlabCiClient({\n discoveryApi,\n gitlabAuthApi,\n identityApi,\n codeOwnersPath: configApi.getOptionalString(\n 'gitlab.defaultCodeOwnersPath',\n ),\n readmePath: configApi.getOptionalString('gitlab.defaultReadmePath'),\n useOAuth: configApi.getOptionalBoolean('gitlab.useOAuth'),\n }),\n });\n },\n }),\n createApiFactory({\n api: mssvAzureDevopsApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n fetchApi: fetchApiRef,\n },\n factory: ({ discoveryApi, fetchApi }) => {\n return new MssvAzureDevopsClient({\n azureDevopsApi: new AzureDevOpsClient({\n discoveryApi,\n fetchApi,\n }),\n });\n },\n }),\n ],\n routes: {\n entityContent: rootRouteRef,\n },\n});\n\n/** @public */\nexport const isMultiCIAvailable = (entity: Entity): boolean =>\n isJenkinsAvailable(entity) ||\n isGitlabAvailable(entity) ||\n isGithubActionsAvailable(entity) ||\n isAzurePipelinesAvailable(entity);\n\n/** @public */\nexport const EntityMultiCIPipelinesContent =\n multiSourceSecurityViewerPlugin.provide(\n createRoutableExtension({\n name: 'EntityMultiCIPipelinesContent',\n component: () => import('./components/Router').then(m => m.Router),\n mountPoint: rootRouteRef,\n }),\n );\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAuDO,MAAM,kCAAkC,YAAa,CAAA;AAAA,EAC1D,EAAI,EAAA,8BAAA;AAAA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A,iBAAA,CAAkB,0BAA0B,CAAA;AAAA,YAClE,QAAA,EAAU,SAAU,CAAA,kBAAA,CAAmB,iBAAiB;AAAA,WACzD;AAAA,SACF,CAAA;AAAA;AACH,KACD,CAAA;AAAA,IACD,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,qBAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,YAAc,EAAA,eAAA;AAAA,QACd,QAAU,EAAA;AAAA,OACZ;AAAA,MACA,OAAS,EAAA,CAAC,EAAE,YAAA,EAAc,UAAe,KAAA;AACvC,QAAA,OAAO,IAAI,qBAAsB,CAAA;AAAA,UAC/B,cAAA,EAAgB,IAAI,iBAAkB,CAAA;AAAA,YACpC,YAAA;AAAA,YACA;AAAA,WACD;AAAA,SACF,CAAA;AAAA;AACH,KACD;AAAA,GACH;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,aAAe,EAAA;AAAA;AAEnB,CAAC;AAGM,MAAM,kBAAqB,GAAA,CAAC,MACjC,KAAA,kBAAA,CAAmB,MAAM,CAAA,IACzB,iBAAkB,CAAA,MAAM,CACxB,IAAA,wBAAA,CAAyB,MAAM,CAAA,IAC/B,0BAA0B,MAAM;AAG3B,MAAM,gCACX,+BAAgC,CAAA,OAAA;AAAA,EAC9B,uBAAwB,CAAA;AAAA,IACtB,IAAM,EAAA,+BAAA;AAAA,IACN,SAAA,EAAW,MAAM,OAAO,4BAAqB,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,MAAM,CAAA;AAAA,IACjE,UAAY,EAAA;AAAA,GACb;AACH;;;;"}
@@ -3,19 +3,19 @@ const cleanLogs = (logs) => {
3
3
  };
4
4
  const extractJSON = (logs, startAnchor, endAnchor) => {
5
5
  const cleanedLogs = cleanLogs(logs);
6
- const regex = new RegExp(`${startAnchor}(.*)${endAnchor}`, "s");
6
+ const regex = new RegExp(`${startAnchor}(.*?)${endAnchor}`, "s");
7
7
  const match = cleanedLogs.match(regex);
8
8
  if (!match) {
9
9
  return void 0;
10
10
  }
11
- const lines = match[1].split("\n");
12
11
  const timestampPattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z/g;
13
- const cleanMatch = lines.reduce((acc, cv) => {
14
- acc.push(cv.replace(timestampPattern, ""));
15
- return acc;
16
- }, []).join(" ");
12
+ const cleanMatch = match[1].split("\n").reduce((acc, line) => {
13
+ const cleanedLine = line.replace(timestampPattern, "").trim();
14
+ if (!cleanedLine) return acc;
15
+ return `${acc} ${cleanedLine}`;
16
+ }, "");
17
17
  try {
18
- return JSON.parse(cleanMatch.trim());
18
+ return JSON.parse(cleanMatch);
19
19
  } catch (e) {
20
20
  return void 0;
21
21
  }
@@ -23,12 +23,15 @@ const extractJSON = (logs, startAnchor, endAnchor) => {
23
23
  const extractPipelineSteps = (stepLogs) => {
24
24
  const cleanedLogs = cleanLogs(stepLogs);
25
25
  const stepLines = cleanedLogs.split("Step: ");
26
- return stepLines.slice(1).map((stepLine) => {
27
- const lines = stepLine.split("\n");
28
- const name = lines[0];
29
- const logs = lines.slice(1).join("\n");
30
- return { name, logs };
31
- });
26
+ const knownSteps = /* @__PURE__ */ new Set();
27
+ return stepLines.slice(1).reduce((acc, stepLine) => {
28
+ const [name, ...logs] = stepLine.split("\n");
29
+ if (!knownSteps.has(name)) {
30
+ acc.push({ name, logs: logs.join("\n") });
31
+ knownSteps.add(name);
32
+ }
33
+ return acc;
34
+ }, []);
32
35
  };
33
36
 
34
37
  export { cleanLogs, extractJSON, extractPipelineSteps };
@@ -1 +1 @@
1
- {"version":3,"file":"logs.esm.js","sources":["../../src/utils/logs.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { PipelineRunLogStep } from '../types/pipelinerun';\n\n/*\n * Clean escaped characters from logs\n * @param logs: string\n * @returns string\n * */\nexport const cleanLogs = (logs: string): string => {\n return !logs\n ? ''\n : logs.replace(/\\\\\"/g, '\"').replace(/\\\\n/g, '\\n').replace(/\\\\\\\\/g, '');\n};\n\n/*\n * Extract JSON between two anchors (EYE_CATCHERS)\n * @param logs: string\n * @returns Record<string, any> | undefined\n */\nexport const extractJSON = (\n logs: string,\n startAnchor: string,\n endAnchor: string,\n): Record<string, any> | undefined => {\n const cleanedLogs = cleanLogs(logs);\n const regex = new RegExp(`${startAnchor}(.*)${endAnchor}`, 's');\n const match = cleanedLogs.match(regex);\n\n if (!match) {\n return undefined;\n }\n\n const lines = match[1].split('\\n');\n // Remove log timestamp till timezone\n const timestampPattern = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d+Z/g;\n const cleanMatch: string = lines\n .reduce((acc: string[], cv: string) => {\n acc.push(cv.replace(timestampPattern, ''));\n return acc;\n }, [])\n .join(' ');\n\n try {\n return JSON.parse(cleanMatch.trim());\n } catch (e) {\n return undefined;\n }\n};\n\n/*\n * Extract Pipelinesteps from logs\n * @param stepLogs: string\n * @returns PipelineRunLogStep[]\n */\nexport const extractPipelineSteps = (\n stepLogs: string,\n): PipelineRunLogStep[] => {\n // TODO: Async logs may be in incorrect order\n const cleanedLogs = cleanLogs(stepLogs);\n const stepLines = cleanedLogs.split('Step: ');\n // Skip the first line as it is not a step\n return stepLines.slice(1).map((stepLine: string) => {\n const lines = stepLine.split('\\n');\n const name = lines[0];\n const logs = lines.slice(1).join('\\n');\n return { name, logs };\n });\n};\n"],"names":[],"mappings":"AAsBa,MAAA,SAAA,GAAY,CAAC,IAAyB,KAAA;AACjD,EAAA,OAAO,CAAC,IAAA,GACJ,EACA,GAAA,IAAA,CAAK,QAAQ,MA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,QAAqB,KAAA;AAClD,IAAM,MAAA,KAAA,GAAQ,QAAS,CAAA,KAAA,CAAM,IAAI,CAAA;AACjC,IAAM,MAAA,IAAA,GAAO,MAAM,CAAC,CAAA;AACpB,IAAA,MAAM,OAAO,KAAM,CAAA,KAAA,CAAM,CAAC,CAAA,CAAE,KAAK,IAAI,CAAA;AACrC,IAAO,OAAA,EAAE,MAAM,IAAK,EAAA;AAAA,GACrB,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"logs.esm.js","sources":["../../src/utils/logs.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { PipelineRunLogStep } from '../types/pipelinerun';\n\n/*\n * Clean escaped characters from logs\n * @param logs: string\n * @returns string\n * */\nexport const cleanLogs = (logs: string): string => {\n return !logs\n ? ''\n : logs.replace(/\\\\\"/g, '\"').replace(/\\\\n/g, '\\n').replace(/\\\\\\\\/g, '');\n};\n\n/*\n * Extract JSON between two anchors (EYE_CATCHERS)\n * @param logs: string\n * @returns Record<string, any> | undefined\n */\nexport const extractJSON = (\n logs: string,\n startAnchor: string,\n endAnchor: string,\n): Record<string, any> | undefined => {\n const cleanedLogs = cleanLogs(logs);\n const regex = new RegExp(`${startAnchor}(.*?)${endAnchor}`, 's');\n const match = cleanedLogs.match(regex);\n\n if (!match) {\n return undefined;\n }\n\n // Remove log timestamp till timezone\n const timestampPattern = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d+Z/g;\n const cleanMatch: string = match[1].split('\\n').reduce((acc, line) => {\n const cleanedLine = line.replace(timestampPattern, '').trim();\n if (!cleanedLine) return acc;\n return `${acc} ${cleanedLine}`;\n }, '');\n\n try {\n return JSON.parse(cleanMatch);\n } catch (e) {\n return undefined;\n }\n};\n\n/*\n * Extract Pipelinesteps from logs\n * @param stepLogs: string\n * @returns PipelineRunLogStep[]\n */\nexport const extractPipelineSteps = (\n stepLogs: string,\n): PipelineRunLogStep[] => {\n // TODO: Async logs may be in incorrect order\n const cleanedLogs = cleanLogs(stepLogs);\n const stepLines = cleanedLogs.split('Step: ');\n const knownSteps = new Set<string>();\n // Skip the first line as it is not a step\n return stepLines\n .slice(1)\n .reduce((acc: PipelineRunLogStep[], stepLine: string) => {\n const [name, ...logs] = stepLine.split('\\n');\n // Ignore dupes\n if (!knownSteps.has(name)) {\n acc.push({ name, logs: logs.join('\\n') });\n knownSteps.add(name);\n }\n return acc;\n }, []);\n};\n"],"names":[],"mappings":"AAsBa,MAAA,SAAA,GAAY,CAAC,IAAyB,KAAA;AACjD,EAAA,OAAO,CAAC,IAAA,GACJ,EACA,GAAA,IAAA,CAAK,QAAQ,MAAQ,EAAA,GAAG,CAAE,CAAA,OAAA,CAAQ,MAAQ,EAAA,IAAI,CAAE,CAAA,OAAA,CAAQ,SAAS,EAAE,CAAA;AACzE;AAOO,MAAM,WAAc,GAAA,CACzB,IACA,EAAA,WAAA,EACA,SACoC,KAAA;AACpC,EAAM,MAAA,WAAA,GAAc,UAAU,IAAI,CAAA;AAClC,EAAM,MAAA,KAAA,GAAQ,IAAI,MAAO,CAAA,CAAA,EAAG,WAAW,CAAQ,KAAA,EAAA,SAAS,IAAI,GAAG,CAAA;AAC/D,EAAM,MAAA,KAAA,GAAQ,WAAY,CAAA,KAAA,CAAM,KAAK,CAAA;AAErC,EAAA,IAAI,CAAC,KAAO,EAAA;AACV,IAAO,OAAA,KAAA,CAAA;AAAA;AAIT,EAAA,MAAM,gBAAmB,GAAA,6CAAA;AACzB,EAAM,MAAA,UAAA,GAAqB,KAAM,CAAA,CAAC,CAA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"dist/index.esm.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -40,7 +40,9 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@aonic-ui/pipelines": "^3.1.1",
43
- "@backstage-community/plugin-github-actions": "^0.8.0",
43
+ "@backstage-community/plugin-azure-devops": "^0.13.0",
44
+ "@backstage-community/plugin-azure-devops-common": "^0.9.0",
45
+ "@backstage-community/plugin-github-actions": "^0.9.0",
44
46
  "@backstage-community/plugin-jenkins": "^0.17.0",
45
47
  "@backstage-community/plugin-multi-source-security-viewer-common": "^0.1.1",
46
48
  "@backstage/catalog-model": "^1.7.3",