@backstage-community/plugin-allure 0.1.51

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/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # [Allure](https://docs.qameta.io/allure/)
2
+
3
+ Welcome to the Backstage Allure plugin. This plugin add an entity service page to display Allure test reports related to the service.
4
+
5
+ ## Install
6
+
7
+ ```shell
8
+ # From your Backstage root directory
9
+ yarn --cwd packages/app add @backstage-community/plugin-allure
10
+ ```
11
+
12
+ ## Configure
13
+
14
+ ### Configure Allure service
15
+
16
+ Add below configuration in the `app-config.yaml`.
17
+
18
+ ```yaml
19
+ allure:
20
+ baseUrl: <ALLURE_SERVICE_BASE_URL> # Example: https://allure.my-company.net or when running allure locally, http://localhost:5050/allure-docker-service
21
+ ```
22
+
23
+ ### Setup entity service page
24
+
25
+ Add `EntityAllureReportContent` in the `EntityPage.tsx` like below:
26
+
27
+ ```diff
28
+ + import { EntityAllureReportContent } from '@backstage-community/plugin-allure';
29
+
30
+ ...
31
+
32
+ const serviceEntityPage = (
33
+ <EntityLayoutWrapper>
34
+ ...
35
+ + <EntityLayout.Route path="/allure" title="Allure Report">
36
+ + <EntityAllureReportContent />
37
+ + </EntityLayout.Route>
38
+ </EntityLayoutWrapper>
39
+ );
40
+ ```
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import { useApi } from '@backstage/core-plugin-api';
3
+ import { i as isAllureReportAvailable, A as ALLURE_PROJECT_ID_ANNOTATION, a as allureApiRef, g as getAllureProjectId } from './index-i1EiZshE.esm.js';
4
+ import { useEntity, MissingAnnotationEmptyState } from '@backstage/plugin-catalog-react';
5
+ import { Progress } from '@backstage/core-components';
6
+ import useAsync from 'react-use/esm/useAsync';
7
+
8
+ const AllureReport = (props) => {
9
+ const allureApi = useApi(allureApiRef);
10
+ const allureProjectId = getAllureProjectId(props.entity);
11
+ const { value, loading } = useAsync(async () => {
12
+ const url = await allureApi.getReportUrl(allureProjectId);
13
+ return url;
14
+ });
15
+ if (loading) {
16
+ return /* @__PURE__ */ React.createElement(Progress, null);
17
+ }
18
+ return /* @__PURE__ */ React.createElement(
19
+ "iframe",
20
+ {
21
+ style: {
22
+ display: "table",
23
+ width: "100%",
24
+ height: "100%"
25
+ },
26
+ title: "Allure Report",
27
+ src: value
28
+ }
29
+ );
30
+ };
31
+ const AllureReportComponent = () => {
32
+ const { entity } = useEntity();
33
+ const isReportAvailable = entity && isAllureReportAvailable(entity);
34
+ if (isReportAvailable)
35
+ return /* @__PURE__ */ React.createElement(AllureReport, { entity });
36
+ return /* @__PURE__ */ React.createElement(MissingAnnotationEmptyState, { annotation: ALLURE_PROJECT_ID_ANNOTATION });
37
+ };
38
+
39
+ export { AllureReportComponent };
40
+ //# sourceMappingURL=index-DMPeCQyc.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DMPeCQyc.esm.js","sources":["../../src/components/AllureReportComponent/AllureReportComponent.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 { useApi } from '@backstage/core-plugin-api';\nimport { allureApiRef } from '../../api';\nimport {\n useEntity,\n MissingAnnotationEmptyState,\n} from '@backstage/plugin-catalog-react';\nimport {\n ALLURE_PROJECT_ID_ANNOTATION,\n isAllureReportAvailable,\n getAllureProjectId,\n} from '../annotationHelpers';\nimport { Progress } from '@backstage/core-components';\nimport useAsync from 'react-use/esm/useAsync';\nimport { Entity } from '@backstage/catalog-model';\n\nconst AllureReport = (props: { entity: Entity }) => {\n const allureApi = useApi(allureApiRef);\n\n const allureProjectId = getAllureProjectId(props.entity);\n const { value, loading } = useAsync(async () => {\n const url = await allureApi.getReportUrl(allureProjectId);\n return url;\n });\n\n if (loading) {\n return <Progress />;\n }\n return (\n <iframe\n style={{\n display: 'table',\n width: '100%',\n height: '100%',\n }}\n title=\"Allure Report\"\n src={value}\n />\n );\n};\n\nexport const AllureReportComponent = () => {\n const { entity } = useEntity();\n const isReportAvailable = entity && isAllureReportAvailable(entity);\n\n if (isReportAvailable) return <AllureReport entity={entity} />;\n return (\n <MissingAnnotationEmptyState annotation={ALLURE_PROJECT_ID_ANNOTATION} />\n );\n};\n"],"names":[],"mappings":";;;;;;;AA+BA,MAAM,YAAA,GAAe,CAAC,KAA8B,KAAA;AAClD,EAAM,MAAA,SAAA,GAAY,OAAO,YAAY,CAAA,CAAA;AAErC,EAAM,MAAA,eAAA,GAAkB,kBAAmB,CAAA,KAAA,CAAM,MAAM,CAAA,CAAA;AACvD,EAAA,MAAM,EAAE,KAAA,EAAO,OAAQ,EAAA,GAAI,SAAS,YAAY;AAC9C,IAAA,MAAM,GAAM,GAAA,MAAM,SAAU,CAAA,YAAA,CAAa,eAAe,CAAA,CAAA;AACxD,IAAO,OAAA,GAAA,CAAA;AAAA,GACR,CAAA,CAAA;AAED,EAAA,IAAI,OAAS,EAAA;AACX,IAAA,2CAAQ,QAAS,EAAA,IAAA,CAAA,CAAA;AAAA,GACnB;AACA,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,KAAO,EAAA;AAAA,QACL,OAAS,EAAA,OAAA;AAAA,QACT,KAAO,EAAA,MAAA;AAAA,QACP,MAAQ,EAAA,MAAA;AAAA,OACV;AAAA,MACA,KAAM,EAAA,eAAA;AAAA,MACN,GAAK,EAAA,KAAA;AAAA,KAAA;AAAA,GACP,CAAA;AAEJ,CAAA,CAAA;AAEO,MAAM,wBAAwB,MAAM;AACzC,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA,CAAA;AAC7B,EAAM,MAAA,iBAAA,GAAoB,MAAU,IAAA,uBAAA,CAAwB,MAAM,CAAA,CAAA;AAElE,EAAI,IAAA,iBAAA;AAAmB,IAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,gBAAa,MAAgB,EAAA,CAAA,CAAA;AAC5D,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,2BAA4B,EAAA,EAAA,UAAA,EAAY,4BAA8B,EAAA,CAAA,CAAA;AAE3E;;;;"}
@@ -0,0 +1,63 @@
1
+ import { createApiRef, createRouteRef, createPlugin, createApiFactory, configApiRef, createRoutableExtension } from '@backstage/core-plugin-api';
2
+
3
+ const allureApiRef = createApiRef({
4
+ id: "allure-api"
5
+ });
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __publicField = (obj, key, value) => {
10
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
11
+ return value;
12
+ };
13
+ class AllureApiClient {
14
+ constructor(options) {
15
+ __publicField(this, "configApi");
16
+ this.configApi = options.configApi;
17
+ }
18
+ async getReportUrl(projectId) {
19
+ const baseUrl = this.configApi.getString("allure.baseUrl");
20
+ return `${baseUrl}/projects/${projectId}/reports/latest/index.html`;
21
+ }
22
+ }
23
+
24
+ const allureRouteRef = createRouteRef({
25
+ id: "allure"
26
+ });
27
+ const allurePlugin = createPlugin({
28
+ id: "allure",
29
+ apis: [
30
+ createApiFactory({
31
+ api: allureApiRef,
32
+ deps: {
33
+ configApi: configApiRef
34
+ },
35
+ factory: ({ configApi }) => new AllureApiClient({ configApi })
36
+ })
37
+ ],
38
+ routes: {
39
+ root: allureRouteRef
40
+ }
41
+ });
42
+ const EntityAllureReportContent = allurePlugin.provide(
43
+ createRoutableExtension({
44
+ name: "EntityAllureReportContent",
45
+ component: () => import('./index-DMPeCQyc.esm.js').then(
46
+ (m) => m.AllureReportComponent
47
+ ),
48
+ mountPoint: allureRouteRef
49
+ })
50
+ );
51
+
52
+ const ALLURE_PROJECT_ID_ANNOTATION = "qameta.io/allure-project";
53
+ const isAllureReportAvailable = (entity) => {
54
+ var _a;
55
+ return Boolean((_a = entity.metadata.annotations) == null ? void 0 : _a[ALLURE_PROJECT_ID_ANNOTATION]);
56
+ };
57
+ const getAllureProjectId = (entity) => {
58
+ var _a, _b;
59
+ return (_b = (_a = entity == null ? void 0 : entity.metadata.annotations) == null ? void 0 : _a[ALLURE_PROJECT_ID_ANNOTATION]) != null ? _b : "";
60
+ };
61
+
62
+ export { ALLURE_PROJECT_ID_ANNOTATION as A, EntityAllureReportContent as E, allureApiRef as a, allurePlugin as b, getAllureProjectId as g, isAllureReportAvailable as i };
63
+ //# sourceMappingURL=index-i1EiZshE.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-i1EiZshE.esm.js","sources":["../../src/api/AllureApi.ts","../../src/api/AllureApiClient.ts","../../src/plugin.ts","../../src/components/annotationHelpers.ts"],"sourcesContent":["/*\n * Copyright 2021 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';\n\nexport type AllureApi = {\n getReportUrl(projectId: string): Promise<string>;\n};\n\nexport const allureApiRef = createApiRef<AllureApi>({\n id: 'allure-api',\n});\n","/*\n * Copyright 2021 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 { ConfigApi } from '@backstage/core-plugin-api';\nimport { AllureApi } from './AllureApi';\n\nexport class AllureApiClient implements AllureApi {\n readonly configApi: ConfigApi;\n\n constructor(options: { configApi: ConfigApi }) {\n this.configApi = options.configApi;\n }\n\n async getReportUrl(projectId: string): Promise<string> {\n const baseUrl = this.configApi.getString('allure.baseUrl');\n return `${baseUrl}/projects/${projectId}/reports/latest/index.html`;\n }\n}\n","/*\n * Copyright 2021 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 {\n configApiRef,\n createApiFactory,\n createPlugin,\n createRoutableExtension,\n createRouteRef,\n} from '@backstage/core-plugin-api';\nimport { AllureApiClient, allureApiRef } from './api';\n\nexport const allureRouteRef = createRouteRef({\n id: 'allure',\n});\n\n/** @public */\nexport const allurePlugin = createPlugin({\n id: 'allure',\n apis: [\n createApiFactory({\n api: allureApiRef,\n deps: {\n configApi: configApiRef,\n },\n factory: ({ configApi }) => new AllureApiClient({ configApi }),\n }),\n ],\n routes: {\n root: allureRouteRef,\n },\n});\n\n/** @public */\nexport const EntityAllureReportContent = allurePlugin.provide(\n createRoutableExtension({\n name: 'EntityAllureReportContent',\n component: () =>\n import('./components/AllureReportComponent').then(\n m => m.AllureReportComponent,\n ),\n mountPoint: allureRouteRef,\n }),\n);\n","/*\n * Copyright 2021 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 { Entity } from '@backstage/catalog-model';\n\n/** @public */\nexport const ALLURE_PROJECT_ID_ANNOTATION = 'qameta.io/allure-project';\n\n/** @public */\nexport const isAllureReportAvailable = (entity: Entity) =>\n Boolean(entity.metadata.annotations?.[ALLURE_PROJECT_ID_ANNOTATION]);\n\nexport const getAllureProjectId = (entity: Entity) => {\n return entity?.metadata.annotations?.[ALLURE_PROJECT_ID_ANNOTATION] ?? '';\n};\n"],"names":[],"mappings":";;AAqBO,MAAM,eAAe,YAAwB,CAAA;AAAA,EAClD,EAAI,EAAA,YAAA;AACN,CAAC;;;;;;;;ACLM,MAAM,eAAqC,CAAA;AAAA,EAGhD,YAAY,OAAmC,EAAA;AAF/C,IAAS,aAAA,CAAA,IAAA,EAAA,WAAA,CAAA,CAAA;AAGP,IAAA,IAAA,CAAK,YAAY,OAAQ,CAAA,SAAA,CAAA;AAAA,GAC3B;AAAA,EAEA,MAAM,aAAa,SAAoC,EAAA;AACrD,IAAA,MAAM,OAAU,GAAA,IAAA,CAAK,SAAU,CAAA,SAAA,CAAU,gBAAgB,CAAA,CAAA;AACzD,IAAO,OAAA,CAAA,EAAG,OAAO,CAAA,UAAA,EAAa,SAAS,CAAA,0BAAA,CAAA,CAAA;AAAA,GACzC;AACF;;ACLO,MAAM,iBAAiB,cAAe,CAAA;AAAA,EAC3C,EAAI,EAAA,QAAA;AACN,CAAC,CAAA,CAAA;AAGM,MAAM,eAAe,YAAa,CAAA;AAAA,EACvC,EAAI,EAAA,QAAA;AAAA,EACJ,IAAM,EAAA;AAAA,IACJ,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,YAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,SAAW,EAAA,YAAA;AAAA,OACb;AAAA,MACA,OAAA,EAAS,CAAC,EAAE,SAAA,OAAgB,IAAI,eAAA,CAAgB,EAAE,SAAA,EAAW,CAAA;AAAA,KAC9D,CAAA;AAAA,GACH;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,cAAA;AAAA,GACR;AACF,CAAC,EAAA;AAGM,MAAM,4BAA4B,YAAa,CAAA,OAAA;AAAA,EACpD,uBAAwB,CAAA;AAAA,IACtB,IAAM,EAAA,2BAAA;AAAA,IACN,SAAW,EAAA,MACT,OAAO,yBAAoC,CAAE,CAAA,IAAA;AAAA,MAC3C,OAAK,CAAE,CAAA,qBAAA;AAAA,KACT;AAAA,IACF,UAAY,EAAA,cAAA;AAAA,GACb,CAAA;AACH;;ACrCO,MAAM,4BAA+B,GAAA,2BAAA;AAG/B,MAAA,uBAAA,GAA0B,CAAC,MAAgB,KAAA;AArBxD,EAAA,IAAA,EAAA,CAAA;AAsBE,EAAA,OAAA,OAAA,CAAA,CAAQ,EAAO,GAAA,MAAA,CAAA,QAAA,CAAS,WAAhB,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAA8B,4BAA6B,CAAA,CAAA,CAAA;AAAA,EAAA;AAExD,MAAA,kBAAA,GAAqB,CAAC,MAAmB,KAAA;AAxBtD,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AAyBE,EAAA,OAAA,CAAO,EAAQ,GAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,MAAA,CAAA,QAAA,CAAS,WAAjB,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAA+B,kCAA/B,IAAgE,GAAA,EAAA,GAAA,EAAA,CAAA;AACzE;;;;"}
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ import * as react from 'react';
3
+ import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
4
+ import { Entity } from '@backstage/catalog-model';
5
+
6
+ /** @public */
7
+ declare const allurePlugin: _backstage_core_plugin_api.BackstagePlugin<{
8
+ root: _backstage_core_plugin_api.RouteRef<undefined>;
9
+ }, {}, {}>;
10
+ /** @public */
11
+ declare const EntityAllureReportContent: () => react.JSX.Element;
12
+
13
+ /** @public */
14
+ declare const ALLURE_PROJECT_ID_ANNOTATION = "qameta.io/allure-project";
15
+ /** @public */
16
+ declare const isAllureReportAvailable: (entity: Entity) => boolean;
17
+
18
+ export { ALLURE_PROJECT_ID_ANNOTATION, EntityAllureReportContent, allurePlugin, isAllureReportAvailable };
@@ -0,0 +1,3 @@
1
+ export { A as ALLURE_PROJECT_ID_ANNOTATION, E as EntityAllureReportContent, b as allurePlugin, i as isAllureReportAvailable } from './esm/index-i1EiZshE.esm.js';
2
+ import '@backstage/core-plugin-api';
3
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@backstage-community/plugin-allure",
3
+ "version": "0.1.51",
4
+ "description": "A Backstage plugin that integrates with Allure",
5
+ "backstage": {
6
+ "role": "frontend-plugin"
7
+ },
8
+ "publishConfig": {
9
+ "access": "public",
10
+ "main": "dist/index.esm.js",
11
+ "types": "dist/index.d.ts"
12
+ },
13
+ "homepage": "https://backstage.io",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/backstage/community-plugins",
17
+ "directory": "workspaces/allure/plugins/allure"
18
+ },
19
+ "license": "Apache-2.0",
20
+ "sideEffects": false,
21
+ "main": "dist/index.esm.js",
22
+ "types": "dist/index.d.ts",
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "scripts": {
27
+ "build": "backstage-cli package build",
28
+ "clean": "backstage-cli package clean",
29
+ "lint": "backstage-cli package lint",
30
+ "prepack": "backstage-cli package prepack",
31
+ "postpack": "backstage-cli package postpack",
32
+ "start": "backstage-cli package start",
33
+ "test": "backstage-cli package test"
34
+ },
35
+ "dependencies": {
36
+ "@backstage/catalog-model": "^1.4.5",
37
+ "@backstage/core-components": "^0.14.4",
38
+ "@backstage/core-plugin-api": "^1.9.2",
39
+ "@backstage/plugin-catalog-react": "^1.11.3",
40
+ "@types/react": "^16.13.1 || ^17.0.0 || ^18.0.0",
41
+ "react-use": "^17.2.4"
42
+ },
43
+ "devDependencies": {
44
+ "@backstage/cli": "^0.26.3",
45
+ "@backstage/dev-utils": "^1.0.31",
46
+ "@backstage/test-utils": "^1.5.4",
47
+ "@testing-library/dom": "^10.0.0",
48
+ "@testing-library/jest-dom": "^6.0.0",
49
+ "@testing-library/react": "^15.0.0",
50
+ "@types/react-dom": "^18.2.19",
51
+ "canvas": "^2.11.2",
52
+ "msw": "^1.0.0",
53
+ "react": "^16.13.1 || ^17.0.0 || ^18.0.0",
54
+ "react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0",
55
+ "react-router-dom": "6.0.0-beta.0 || ^6.3.0"
56
+ },
57
+ "peerDependencies": {
58
+ "react": "^16.13.1 || ^17.0.0 || ^18.0.0",
59
+ "react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0",
60
+ "react-router-dom": "6.0.0-beta.0 || ^6.3.0"
61
+ },
62
+ "configSchema": {
63
+ "$schema": "https://backstage.io/schema/config-v1",
64
+ "title": "@backstage/allure",
65
+ "type": "object",
66
+ "properties": {
67
+ "allure": {
68
+ "type": "object",
69
+ "properties": {
70
+ "baseUrl": {
71
+ "type": "string",
72
+ "visibility": "frontend"
73
+ }
74
+ }
75
+ }
76
+ }
77
+ },
78
+ "module": "./dist/index.esm.js"
79
+ }