@backstage-community/plugin-sonarqube 0.8.6 → 0.8.8
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 +13 -0
- package/README.md +1 -23
- package/alpha/package.json +1 -1
- package/config.d.ts +32 -0
- package/dist/alpha/apis.esm.js +4 -4
- package/dist/alpha/apis.esm.js.map +1 -1
- package/dist/alpha/entityCard.esm.js +2 -1
- package/dist/alpha/entityCard.esm.js.map +1 -1
- package/dist/alpha/entityContent.esm.js +2 -1
- package/dist/alpha/entityContent.esm.js.map +1 -1
- package/dist/api/SonarQubeClient.esm.js +7 -10
- package/dist/api/SonarQubeClient.esm.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/plugin.esm.js +4 -4
- package/dist/plugin.esm.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @backstage-community/plugin-sonarqube
|
|
2
2
|
|
|
3
|
+
## 0.8.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e657f8d: Add default filtering based on required annotation to the new frontend system components
|
|
8
|
+
|
|
9
|
+
## 0.8.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 4c50596: Add config visibility to the frontend
|
|
14
|
+
- c05862b: fix: use fetchApi instead of explicit identityApi token in sonarqube frontend plugin api
|
|
15
|
+
|
|
3
16
|
## 0.8.6
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ spec:
|
|
|
85
85
|
|
|
86
86
|
Follow this section if you are using Backstage's [new frontend system](https://backstage.io/docs/frontend-system/).
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
Import `sonarQubePlugin` in your `App.tsx` and add it to your app's `features` array:
|
|
89
89
|
|
|
90
90
|
```typescript
|
|
91
91
|
import sonarQubePlugin from '@backstage-community/plugin-sonarqube/alpha';
|
|
@@ -101,28 +101,6 @@ export const app = createApp({
|
|
|
101
101
|
});
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
2. Next, enable your desired extensions in `app-config.yaml`
|
|
105
|
-
|
|
106
|
-
```yaml
|
|
107
|
-
app:
|
|
108
|
-
extensions:
|
|
109
|
-
- entity-content:sonarqube/entity
|
|
110
|
-
- entity-card:sonarqube/card
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
3. Whichever extensions you've enabled should now appear in your entity page.
|
|
114
|
-
|
|
115
|
-
You can also control which [entity kinds](https://backstage.io/docs/features/software-catalog/system-model) the sonarqube card appears on by adding a config underneath the entity-content, like so:
|
|
116
|
-
|
|
117
|
-
```yaml
|
|
118
|
-
# app-config.yaml
|
|
119
|
-
app:
|
|
120
|
-
extensions:
|
|
121
|
-
- entity-content:sonarqube/entity
|
|
122
|
-
config:
|
|
123
|
-
filter: kind:component,system
|
|
124
|
-
```
|
|
125
|
-
|
|
126
104
|
## Links
|
|
127
105
|
|
|
128
106
|
- [Sonarqube Backend](../sonarqube-backend/README.md)
|
package/alpha/package.json
CHANGED
package/config.d.ts
CHANGED
|
@@ -22,5 +22,37 @@ export interface Config {
|
|
|
22
22
|
* @visibility frontend
|
|
23
23
|
*/
|
|
24
24
|
baseUrl?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The external url of the sonarqube installation.
|
|
28
|
+
* Use this if you want to use a different url for the frontend than the backend.
|
|
29
|
+
* @visibility frontend
|
|
30
|
+
*/
|
|
31
|
+
externalBaseUrl?: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The optional sonarqube instances.
|
|
35
|
+
* @visibility frontend
|
|
36
|
+
*/
|
|
37
|
+
instances?: Array<{
|
|
38
|
+
/**
|
|
39
|
+
* The name of the sonarqube instance.
|
|
40
|
+
* @visibility frontend
|
|
41
|
+
*/
|
|
42
|
+
name: string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The base url of the sonarqube instance.
|
|
46
|
+
* @visibility frontend
|
|
47
|
+
*/
|
|
48
|
+
baseUrl: string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The external url of the sonarqube instance.
|
|
52
|
+
* Use this if you want to use a different url for the frontend than the backend.
|
|
53
|
+
* @visibility frontend
|
|
54
|
+
*/
|
|
55
|
+
externalBaseUrl?: string;
|
|
56
|
+
}>;
|
|
25
57
|
};
|
|
26
58
|
}
|
package/dist/alpha/apis.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApiBlueprint, createApiFactory } from '@backstage/frontend-plugin-api';
|
|
2
2
|
import { SonarQubeClient } from '../api/SonarQubeClient.esm.js';
|
|
3
3
|
import { sonarQubeApiRef } from '@backstage-community/plugin-sonarqube-react';
|
|
4
|
-
import { discoveryApiRef,
|
|
4
|
+
import { discoveryApiRef, fetchApiRef } from '@backstage/core-plugin-api';
|
|
5
5
|
|
|
6
6
|
const sonarQubeApi = ApiBlueprint.make({
|
|
7
7
|
params: {
|
|
@@ -9,11 +9,11 @@ const sonarQubeApi = ApiBlueprint.make({
|
|
|
9
9
|
api: sonarQubeApiRef,
|
|
10
10
|
deps: {
|
|
11
11
|
discoveryApi: discoveryApiRef,
|
|
12
|
-
|
|
12
|
+
fetchApi: fetchApiRef
|
|
13
13
|
},
|
|
14
|
-
factory: ({ discoveryApi,
|
|
14
|
+
factory: ({ discoveryApi, fetchApi }) => new SonarQubeClient({
|
|
15
15
|
discoveryApi,
|
|
16
|
-
|
|
16
|
+
fetchApi
|
|
17
17
|
})
|
|
18
18
|
})
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apis.esm.js","sources":["../../src/alpha/apis.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 { ApiBlueprint, createApiFactory } from '@backstage/frontend-plugin-api';\nimport { SonarQubeClient } from '../api';\nimport { sonarQubeApiRef } from '@backstage-community/plugin-sonarqube-react';\nimport { discoveryApiRef,
|
|
1
|
+
{"version":3,"file":"apis.esm.js","sources":["../../src/alpha/apis.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 { ApiBlueprint, createApiFactory } from '@backstage/frontend-plugin-api';\nimport { SonarQubeClient } from '../api';\nimport { sonarQubeApiRef } from '@backstage-community/plugin-sonarqube-react';\nimport { discoveryApiRef, fetchApiRef } from '@backstage/core-plugin-api';\n\n/**\n * @alpha\n */\nexport const sonarQubeApi = ApiBlueprint.make({\n params: {\n factory: createApiFactory({\n api: sonarQubeApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n fetchApi: fetchApiRef,\n },\n factory: ({ discoveryApi, fetchApi }) =>\n new SonarQubeClient({\n discoveryApi,\n fetchApi,\n }),\n }),\n },\n});\n"],"names":[],"mappings":";;;;;AAuBa,MAAA,YAAA,GAAe,aAAa,IAAK,CAAA;AAAA,EAC5C,MAAQ,EAAA;AAAA,IACN,SAAS,gBAAiB,CAAA;AAAA,MACxB,GAAK,EAAA,eAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,YAAc,EAAA,eAAA;AAAA,QACd,QAAU,EAAA,WAAA;AAAA,OACZ;AAAA,MACA,SAAS,CAAC,EAAE,cAAc,QAAS,EAAA,KACjC,IAAI,eAAgB,CAAA;AAAA,QAClB,YAAA;AAAA,QACA,QAAA;AAAA,OACD,CAAA;AAAA,KACJ,CAAA;AAAA,GACH;AACF,CAAC;;;;"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { compatWrapper } from '@backstage/core-compat-api';
|
|
2
2
|
import { EntityCardBlueprint } from '@backstage/plugin-catalog-react/alpha';
|
|
3
|
+
import { isSonarQubeAvailable } from '@backstage-community/plugin-sonarqube-react';
|
|
3
4
|
import React from 'react';
|
|
4
5
|
|
|
5
6
|
const entitySonarQubeCard = EntityCardBlueprint.make({
|
|
6
7
|
name: "card",
|
|
7
8
|
params: {
|
|
8
|
-
filter:
|
|
9
|
+
filter: isSonarQubeAvailable,
|
|
9
10
|
loader: () => import('../components/SonarQubeCard/index.esm.js').then(
|
|
10
11
|
(m) => compatWrapper(/* @__PURE__ */ React.createElement(m.SonarQubeCard, null))
|
|
11
12
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityCard.esm.js","sources":["../../src/alpha/entityCard.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 { compatWrapper } from '@backstage/core-compat-api';\nimport { EntityCardBlueprint } from '@backstage/plugin-catalog-react/alpha';\nimport React from 'react';\n\n/**\n * @alpha\n */\nexport const entitySonarQubeCard: any = EntityCardBlueprint.make({\n name: 'card',\n params: {\n filter:
|
|
1
|
+
{"version":3,"file":"entityCard.esm.js","sources":["../../src/alpha/entityCard.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 { compatWrapper } from '@backstage/core-compat-api';\nimport { EntityCardBlueprint } from '@backstage/plugin-catalog-react/alpha';\nimport { isSonarQubeAvailable } from '@backstage-community/plugin-sonarqube-react';\nimport React from 'react';\n\n/**\n * @alpha\n */\nexport const entitySonarQubeCard: any = EntityCardBlueprint.make({\n name: 'card',\n params: {\n filter: isSonarQubeAvailable,\n loader: () =>\n import('../components/SonarQubeCard').then(m =>\n compatWrapper(<m.SonarQubeCard />),\n ),\n },\n});\n"],"names":[],"mappings":";;;;;AAuBa,MAAA,mBAAA,GAA2B,oBAAoB,IAAK,CAAA;AAAA,EAC/D,IAAM,EAAA,MAAA;AAAA,EACN,MAAQ,EAAA;AAAA,IACN,MAAQ,EAAA,oBAAA;AAAA,IACR,MAAQ,EAAA,MACN,OAAO,0CAA6B,CAAE,CAAA,IAAA;AAAA,MAAK,OACzC,aAAc,iBAAA,KAAA,CAAA,aAAA,CAAC,CAAE,CAAA,aAAA,EAAF,IAAgB,CAAE,CAAA;AAAA,KACnC;AAAA,GACJ;AACF,CAAC;;;;"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha';
|
|
3
|
+
import { isSonarQubeAvailable } from '@backstage-community/plugin-sonarqube-react';
|
|
3
4
|
|
|
4
5
|
const entitySonarQubeContent = EntityContentBlueprint.make({
|
|
5
6
|
name: "entity",
|
|
6
7
|
params: {
|
|
7
8
|
defaultPath: "sonarqube",
|
|
8
9
|
defaultTitle: "SonarQube",
|
|
9
|
-
filter:
|
|
10
|
+
filter: isSonarQubeAvailable,
|
|
10
11
|
loader: () => import('../components/SonarQubeContentPage/index.esm.js').then((m) => /* @__PURE__ */ React.createElement(m.SonarQubeContentPage, null))
|
|
11
12
|
}
|
|
12
13
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityContent.esm.js","sources":["../../src/alpha/entityContent.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 { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha';\n\n/**\n * @alpha\n */\nexport const entitySonarQubeContent = EntityContentBlueprint.make({\n name: 'entity',\n params: {\n defaultPath: 'sonarqube',\n defaultTitle: 'SonarQube',\n filter:
|
|
1
|
+
{"version":3,"file":"entityContent.esm.js","sources":["../../src/alpha/entityContent.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 { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha';\nimport { isSonarQubeAvailable } from '@backstage-community/plugin-sonarqube-react';\n\n/**\n * @alpha\n */\nexport const entitySonarQubeContent = EntityContentBlueprint.make({\n name: 'entity',\n params: {\n defaultPath: 'sonarqube',\n defaultTitle: 'SonarQube',\n filter: isSonarQubeAvailable,\n loader: () =>\n import('../components/SonarQubeContentPage').then(m => (\n <m.SonarQubeContentPage />\n )),\n },\n});\n"],"names":[],"mappings":";;;;AAsBa,MAAA,sBAAA,GAAyB,uBAAuB,IAAK,CAAA;AAAA,EAChE,IAAM,EAAA,QAAA;AAAA,EACN,MAAQ,EAAA;AAAA,IACN,WAAa,EAAA,WAAA;AAAA,IACb,YAAc,EAAA,WAAA;AAAA,IACd,MAAQ,EAAA,oBAAA;AAAA,IACR,MAAA,EAAQ,MACN,OAAO,iDAAoC,CAAA,CAAE,IAAK,CAAA,CAAA,CAAA,qBAC/C,KAAA,CAAA,aAAA,CAAA,CAAA,CAAE,oBAAF,EAAA,IAAuB,CACzB,CAAA;AAAA,GACL;AACF,CAAC;;;;"}
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import fetch from 'cross-fetch';
|
|
2
|
-
|
|
3
1
|
class SonarQubeClient {
|
|
4
2
|
discoveryApi;
|
|
5
|
-
|
|
3
|
+
fetchApi;
|
|
6
4
|
constructor(options) {
|
|
7
5
|
this.discoveryApi = options.discoveryApi;
|
|
8
|
-
this.
|
|
6
|
+
this.fetchApi = options.fetchApi;
|
|
9
7
|
}
|
|
10
8
|
async callApi(path, query) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const response = await this.fetchApi.fetch(
|
|
10
|
+
`${await this.discoveryApi.getBaseUrl(
|
|
11
|
+
"sonarqube"
|
|
12
|
+
)}/${path}?${new URLSearchParams(query).toString()}`,
|
|
15
13
|
{
|
|
16
14
|
headers: {
|
|
17
|
-
"Content-Type": "application/json"
|
|
18
|
-
...idToken && { Authorization: `Bearer ${idToken}` }
|
|
15
|
+
"Content-Type": "application/json"
|
|
19
16
|
}
|
|
20
17
|
}
|
|
21
18
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SonarQubeClient.esm.js","sources":["../../src/api/SonarQubeClient.ts"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport
|
|
1
|
+
{"version":3,"file":"SonarQubeClient.esm.js","sources":["../../src/api/SonarQubeClient.ts"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport {\n FindingSummary,\n Metrics,\n SonarQubeApi,\n} from '@backstage-community/plugin-sonarqube-react';\nimport { InstanceUrlWrapper, FindingsWrapper } from './types';\nimport { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\n\n/** @public */\nexport class SonarQubeClient implements SonarQubeApi {\n discoveryApi: DiscoveryApi;\n fetchApi: FetchApi;\n\n constructor(options: { discoveryApi: DiscoveryApi; fetchApi: FetchApi }) {\n this.discoveryApi = options.discoveryApi;\n this.fetchApi = options.fetchApi;\n }\n\n private async callApi<T>(\n path: string,\n query: { [key in string]: any },\n ): Promise<T | undefined> {\n const response = await this.fetchApi.fetch(\n `${await this.discoveryApi.getBaseUrl(\n 'sonarqube',\n )}/${path}?${new URLSearchParams(query).toString()}`,\n {\n headers: {\n 'Content-Type': 'application/json',\n },\n },\n );\n if (response.status === 200) {\n return (await response.json()) as T;\n }\n return undefined;\n }\n\n async getFindingSummary({\n componentKey,\n projectInstance,\n }: {\n componentKey?: string;\n projectInstance?: string;\n } = {}): Promise<FindingSummary | undefined> {\n if (!componentKey) {\n return undefined;\n }\n\n const instanceKey = projectInstance || '';\n\n const metrics: Metrics = {\n alert_status: undefined,\n bugs: undefined,\n reliability_rating: undefined,\n vulnerabilities: undefined,\n security_rating: undefined,\n security_hotspots_reviewed: undefined,\n security_review_rating: undefined,\n code_smells: undefined,\n sqale_rating: undefined,\n coverage: undefined,\n duplicated_lines_density: undefined,\n };\n\n const baseUrlWrapper = await this.callApi<InstanceUrlWrapper>(\n 'instanceUrl',\n {\n instanceKey,\n },\n );\n let baseUrl = baseUrlWrapper?.instanceUrl;\n if (!baseUrl) {\n return undefined;\n }\n // ensure trailing slash for later on\n if (!baseUrl.endsWith('/')) {\n baseUrl += '/';\n }\n\n const findings = await this.callApi<FindingsWrapper>('findings', {\n componentKey,\n instanceKey,\n });\n if (!findings) {\n return undefined;\n }\n\n findings.measures.forEach(m => {\n metrics[m.metric] = m.value;\n });\n\n return {\n title: componentKey,\n lastAnalysis: findings.analysisDate,\n metrics,\n projectUrl: `${baseUrl}dashboard?id=${encodeURIComponent(componentKey)}`,\n getIssuesUrl: identifier =>\n `${baseUrl}project/issues?id=${encodeURIComponent(\n componentKey,\n )}&types=${identifier.toLocaleUpperCase('en-US')}&resolved=false`,\n getComponentMeasuresUrl: identifier =>\n `${baseUrl}component_measures?id=${encodeURIComponent(\n componentKey,\n )}&metric=${identifier.toLocaleLowerCase(\n 'en-US',\n )}&resolved=false&view=list`,\n getSecurityHotspotsUrl: () =>\n `${baseUrl}${\n baseUrl === 'https://sonarcloud.io/' ? 'project/' : ''\n }security_hotspots?id=${encodeURIComponent(componentKey)}`,\n };\n }\n settledResponseOf(responses: PromiseSettledResult<any>[]): Array<any> {\n return responses.map(response =>\n response.status === 'fulfilled' ? response.value : null,\n );\n }\n\n async getFindingSummaries(\n components: Array<{\n projectInstance: string | undefined;\n componentKey: string;\n }>,\n ): Promise<Map<string, FindingSummary>> {\n const map = new Map<string, FindingSummary>();\n if (components.length === 0) {\n return map;\n }\n const promises = components.map(({ projectInstance, componentKey }) =>\n this.getFindingSummary({ componentKey, projectInstance }),\n );\n const summaries: any = await Promise.allSettled(promises).then(results => {\n return results\n .map(result => result as PromiseFulfilledResult<FindingSummary>)\n .map(result => result.value);\n });\n\n for await (const summary of summaries) {\n if (!map.has(summary.title)) {\n map.set(summary.title, summary);\n }\n }\n return map;\n }\n}\n"],"names":[],"mappings":"AAyBO,MAAM,eAAwC,CAAA;AAAA,EACnD,YAAA,CAAA;AAAA,EACA,QAAA,CAAA;AAAA,EAEA,YAAY,OAA6D,EAAA;AACvE,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA,CAAA;AAC5B,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,QAAA,CAAA;AAAA,GAC1B;AAAA,EAEA,MAAc,OACZ,CAAA,IAAA,EACA,KACwB,EAAA;AACxB,IAAM,MAAA,QAAA,GAAW,MAAM,IAAA,CAAK,QAAS,CAAA,KAAA;AAAA,MACnC,CAAA,EAAG,MAAM,IAAA,CAAK,YAAa,CAAA,UAAA;AAAA,QACzB,WAAA;AAAA,OACD,IAAI,IAAI,CAAA,CAAA,EAAI,IAAI,eAAgB,CAAA,KAAK,CAAE,CAAA,QAAA,EAAU,CAAA,CAAA;AAAA,MAClD;AAAA,QACE,OAAS,EAAA;AAAA,UACP,cAAgB,EAAA,kBAAA;AAAA,SAClB;AAAA,OACF;AAAA,KACF,CAAA;AACA,IAAI,IAAA,QAAA,CAAS,WAAW,GAAK,EAAA;AAC3B,MAAQ,OAAA,MAAM,SAAS,IAAK,EAAA,CAAA;AAAA,KAC9B;AACA,IAAO,OAAA,KAAA,C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tC,IAAM,MAAA,GAAA,uBAAU,GAA4B,EAAA,CAAA;AAC5C,IAAI,IAAA,UAAA,CAAW,WAAW,CAAG,EAAA;AAC3B,MAAO,OAAA,GAAA,CAAA;AAAA,KACT;AACA,IAAA,MAAM,WAAW,UAAW,CAAA,GAAA;AAAA,MAAI,CAAC,EAAE,eAAA,EAAiB,YAAa,EAAA,KAC/D,KAAK,iBAAkB,CAAA,EAAE,YAAc,EAAA,eAAA,EAAiB,CAAA;AAAA,KAC1D,CAAA;AACA,IAAA,MAAM,YAAiB,MAAM,OAAA,CAAQ,WAAW,QAAQ,CAAA,CAAE,KAAK,CAAW,OAAA,KAAA;AACxE,MAAO,OAAA,OAAA,CACJ,IAAI,CAAU,MAAA,KAAA,MAAgD,EAC9D,GAAI,CAAA,CAAA,MAAA,KAAU,OAAO,KAAK,CAAA,CAAA;AAAA,KAC9B,CAAA,CAAA;AAED,IAAA,WAAA,MAAiB,WAAW,SAAW,EAAA;AACrC,MAAA,IAAI,CAAC,GAAA,CAAI,GAAI,CAAA,OAAA,CAAQ,KAAK,CAAG,EAAA;AAC3B,QAAI,GAAA,CAAA,GAAA,CAAI,OAAQ,CAAA,KAAA,EAAO,OAAO,CAAA,CAAA;AAAA,OAChC;AAAA,KACF;AACA,IAAO,OAAA,GAAA,CAAA;AAAA,GACT;AACF;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SonarQubeApi, FindingSummary } from '@backstage-community/plugin-sonarqube-react';
|
|
3
3
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
4
|
-
import { DiscoveryApi,
|
|
4
|
+
import { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';
|
|
5
5
|
import * as _backstage_catalog_model from '@backstage/catalog-model';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import React__default from 'react';
|
|
@@ -11,10 +11,10 @@ import { InfoCardVariants } from '@backstage/core-components';
|
|
|
11
11
|
/** @public */
|
|
12
12
|
declare class SonarQubeClient implements SonarQubeApi {
|
|
13
13
|
discoveryApi: DiscoveryApi;
|
|
14
|
-
|
|
14
|
+
fetchApi: FetchApi;
|
|
15
15
|
constructor(options: {
|
|
16
16
|
discoveryApi: DiscoveryApi;
|
|
17
|
-
|
|
17
|
+
fetchApi: FetchApi;
|
|
18
18
|
});
|
|
19
19
|
private callApi;
|
|
20
20
|
getFindingSummary({ componentKey, projectInstance, }?: {
|
package/dist/plugin.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SonarQubeClient } from './api/SonarQubeClient.esm.js';
|
|
2
|
-
import { createPlugin, createApiFactory, discoveryApiRef,
|
|
2
|
+
import { createPlugin, createApiFactory, discoveryApiRef, fetchApiRef, createComponentExtension } from '@backstage/core-plugin-api';
|
|
3
3
|
import { sonarQubeApiRef } from '@backstage-community/plugin-sonarqube-react';
|
|
4
4
|
|
|
5
5
|
const sonarQubePlugin = createPlugin({
|
|
@@ -9,11 +9,11 @@ const sonarQubePlugin = createPlugin({
|
|
|
9
9
|
api: sonarQubeApiRef,
|
|
10
10
|
deps: {
|
|
11
11
|
discoveryApi: discoveryApiRef,
|
|
12
|
-
|
|
12
|
+
fetchApi: fetchApiRef
|
|
13
13
|
},
|
|
14
|
-
factory: ({ discoveryApi,
|
|
14
|
+
factory: ({ discoveryApi, fetchApi }) => new SonarQubeClient({
|
|
15
15
|
discoveryApi,
|
|
16
|
-
|
|
16
|
+
fetchApi
|
|
17
17
|
})
|
|
18
18
|
})
|
|
19
19
|
]
|
package/dist/plugin.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport { SonarQubeClient } from './api';\nimport {\n createApiFactory,\n createComponentExtension,\n createPlugin,\n discoveryApiRef,\n
|
|
1
|
+
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport { SonarQubeClient } from './api';\nimport {\n createApiFactory,\n createComponentExtension,\n createPlugin,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/core-plugin-api';\nimport { sonarQubeApiRef } from '@backstage-community/plugin-sonarqube-react';\n\n/** @public */\nexport const sonarQubePlugin = createPlugin({\n id: 'sonarqube',\n apis: [\n createApiFactory({\n api: sonarQubeApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n fetchApi: fetchApiRef,\n },\n factory: ({ discoveryApi, fetchApi }) =>\n new SonarQubeClient({\n discoveryApi,\n fetchApi,\n }),\n }),\n ],\n});\n\n/** @public */\nexport const EntitySonarQubeCard = sonarQubePlugin.provide(\n createComponentExtension({\n name: 'EntitySonarQubeCard',\n component: {\n lazy: () =>\n import('./components/SonarQubeCard').then(m => m.SonarQubeCard),\n },\n }),\n);\n\n/** @public */\nexport const EntitySonarQubeContentPage = sonarQubePlugin.provide(\n createComponentExtension({\n name: 'EntitySonarQubeContentPage',\n component: {\n lazy: () =>\n import('./components/SonarQubeContentPage').then(\n m => m.SonarQubeContentPage,\n ),\n },\n }),\n);\n"],"names":[],"mappings":";;;;AA2BO,MAAM,kBAAkB,YAAa,CAAA;AAAA,EAC1C,EAAI,EAAA,WAAA;AAAA,EACJ,IAAM,EAAA;AAAA,IACJ,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,eAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,YAAc,EAAA,eAAA;AAAA,QACd,QAAU,EAAA,WAAA;AAAA,OACZ;AAAA,MACA,SAAS,CAAC,EAAE,cAAc,QAAS,EAAA,KACjC,IAAI,eAAgB,CAAA;AAAA,QAClB,YAAA;AAAA,QACA,QAAA;AAAA,OACD,CAAA;AAAA,KACJ,CAAA;AAAA,GACH;AACF,CAAC,EAAA;AAGM,MAAM,sBAAsB,eAAgB,CAAA,OAAA;AAAA,EACjD,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,qBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAA,EAAM,MACJ,OAAO,yCAA4B,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,aAAa,CAAA;AAAA,KAClE;AAAA,GACD,CAAA;AACH,EAAA;AAGO,MAAM,6BAA6B,eAAgB,CAAA,OAAA;AAAA,EACxD,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,4BAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAM,EAAA,MACJ,OAAO,gDAAmC,CAAE,CAAA,IAAA;AAAA,QAC1C,OAAK,CAAE,CAAA,oBAAA;AAAA,OACT;AAAA,KACJ;AAAA,GACD,CAAA;AACH;;;;"}
|