@backstage-community/plugin-lighthouse 0.4.20

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,115 @@
1
+ # @backstage-community/plugin-lighthouse
2
+
3
+ A frontend for [lighthouse-audit-service](https://github.com/spotify/lighthouse-audit-service), this plugin allows you to trigger Lighthouse audits on websites and track them over time.
4
+
5
+ ## Introduction
6
+
7
+ Google's [Lighthouse](https://developers.google.com/web/tools/lighthouse) auditing tool for websites
8
+ is a great open-source resource for benchmarking and improving the accessibility, performance, SEO, and best practices of your site.
9
+ At Spotify, we keep track of Lighthouse audit scores over time to look at trends and overall areas for investment.
10
+
11
+ This plugin allows you to generate on-demand Lighthouse audits for websites, and to track the trends for the
12
+ top-level categories of Lighthouse at a glance.
13
+
14
+ You can learn more in our blog post [Introducing Lighthouse for Backstage](https://backstage.io/blog/2020/04/06/lighthouse-plugin).
15
+
16
+ | List of audits | Specific audit |
17
+ | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
18
+ | ![Screen shot of the main Lighthouse plugin page](images/lighthouse-page.png) | ![Screen shot of the resulting audit in the Lighthouse plugin](images/audit-view.png) |
19
+
20
+ In the future, we hope to add support for scheduling audits (which we do internally), as well as allowing
21
+ custom runs of Lighthouse to be ingested (for auditing sites that require authentication or some session state).
22
+
23
+ ## Getting Started
24
+
25
+ To get started, you will need a running instance of [`lighthouse-audit-service`](https://github.com/spotify/lighthouse-audit-service).
26
+ _It's likely you will need to [enable CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) to integrate with Backstage, so initialize the `lighthouse-audit-service` with the environment variable `LAS_CORS` set to `true`._
27
+
28
+ When you have an instance running that Backstage can hook into, first install the plugin into your app:
29
+
30
+ ```bash
31
+ # From your Backstage root directory
32
+ yarn --cwd packages/app add @backstage-community/plugin-lighthouse
33
+ ```
34
+
35
+ Modify your app routes in `App.tsx` to include the `LighthousePage` component exported from the plugin, for example:
36
+
37
+ ```tsx
38
+ // In packages/app/src/App.tsx
39
+ import { LighthousePage } from '@backstage-community/plugin-lighthouse';
40
+
41
+ const routes = (
42
+ <FlatRoutes>
43
+ {/* ...other routes */}
44
+ <Route path="/lighthouse" element={<LighthousePage />} />
45
+ ```
46
+
47
+ Then configure the `lighthouse-audit-service` URL in your [`app-config.yaml`](https://github.com/backstage/backstage/blob/master/app-config.yaml).
48
+
49
+ ```yaml
50
+ backend:
51
+ csp:
52
+ frame-src:
53
+ - http://your-service-url
54
+ lighthouse:
55
+ baseUrl: http://your-service-url
56
+ ```
57
+
58
+ ## Integration with the Catalog
59
+
60
+ The Lighthouse plugin can be integrated into the catalog so that Lighthouse audit information relating to a component
61
+ can be displayed within that component's entity page. In order to link an Entity to its Lighthouse audits, the entity
62
+ must be annotated as follows:
63
+
64
+ ```yaml
65
+ apiVersion: backstage.io/v1alpha1
66
+ kind: Component
67
+ metadata:
68
+ # ...
69
+ annotations:
70
+ lighthouse.com/website-url: # A single website url e.g. https://backstage.io/
71
+ ```
72
+
73
+ > NOTE: The plugin only supports one website URL per component at this time.
74
+
75
+ Add a Lighthouse tab to the entity page:
76
+
77
+ ```tsx
78
+ // In packages/app/src/components/catalog/EntityPage.tsx
79
+ import { EntityLighthouseContent } from '@backstage-community/plugin-lighthouse';
80
+
81
+ const websiteEntityPage = (
82
+ <EntityLayout>
83
+ {/* other tabs... */}
84
+ <EntityLayout.Route path="/lighthouse" title="Lighthouse">
85
+ <EntityLighthouseContent />
86
+ </EntityLayout.Route>
87
+ ```
88
+
89
+ > NOTE: The embedded router renders page content without a header section
90
+ > allowing it to be rendered within a catalog plugin page.
91
+
92
+ Add a **Lighthouse card** to the overview tab on the EntityPage:
93
+
94
+ ```tsx
95
+ // In packages/app/src/components/catalog/EntityPage.tsx
96
+ import {
97
+ EntityLastLighthouseAuditCard,
98
+ isLighthouseAvailable,
99
+ } from '@backstage-community/plugin-lighthouse';
100
+
101
+ const overviewContent = (
102
+ <Grid container spacing={3} alignItems="stretch">
103
+ {/* ...other content */}
104
+ <EntitySwitch>
105
+ <EntitySwitch.Case if={isLighthouseAvailable}>
106
+ <Grid item md={6}>
107
+ <EntityLastLighthouseAuditCard />
108
+ </Grid>
109
+ </EntitySwitch.Case>
110
+ </EntitySwitch>
111
+ ```
112
+
113
+ ## Schedule
114
+
115
+ If you want to run automated scheduled runs, you can install the [@backstage/lighthouse-backend](../lighthouse-backend/README.md) plugin
@@ -0,0 +1,26 @@
1
+ export { LastLighthouseAuditCard } from '../index.esm.js';
2
+ import '@backstage-community/plugin-lighthouse-common';
3
+ import '@backstage/core-plugin-api';
4
+ import 'react';
5
+ import 'react-router-dom';
6
+ import '@backstage/plugin-catalog-react';
7
+ import '@material-ui/core/Button';
8
+ import '@material-ui/core/Grid';
9
+ import '@material-ui/lab/Pagination';
10
+ import 'react-use/esm/useAsync';
11
+ import 'react-use/esm/useLocalStorage';
12
+ import '@material-ui/core/Tab';
13
+ import '@material-ui/core/Tabs';
14
+ import '@material-ui/core/styles';
15
+ import '@material-ui/icons/Close';
16
+ import '@backstage/core-components';
17
+ import '@material-ui/core/Typography';
18
+ import 'react-use/esm/useInterval';
19
+ import '@material-ui/core/List';
20
+ import '@material-ui/core/ListItem';
21
+ import '@material-ui/core/ListItemIcon';
22
+ import '@material-ui/core/ListItemText';
23
+ import '@material-ui/lab/Alert';
24
+ import '@material-ui/core/MenuItem';
25
+ import '@material-ui/core/TextField';
26
+ //# sourceMappingURL=index-DTZMI_cR.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DTZMI_cR.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,41 @@
1
+ /// <reference types="react" />
2
+ import * as _backstage_core_components from '@backstage/core-components';
3
+ import { InfoCardVariants } from '@backstage/core-components';
4
+ import * as react from 'react';
5
+ import react__default from 'react';
6
+ import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
7
+ import { Entity } from '@backstage/catalog-model';
8
+ import { LighthouseApi } from '@backstage-community/plugin-lighthouse-common';
9
+
10
+ /** @public */
11
+ declare const lighthousePlugin: _backstage_core_plugin_api.BackstagePlugin<{
12
+ root: _backstage_core_plugin_api.RouteRef<undefined>;
13
+ entityContent: _backstage_core_plugin_api.RouteRef<undefined>;
14
+ }, {}, {}>;
15
+ /** @public */
16
+ declare const LighthousePage: () => react.JSX.Element;
17
+ /** @public */
18
+ declare const EntityLighthouseContent: () => react.JSX.Element;
19
+ /** @public */
20
+ declare const EntityLastLighthouseAuditCard: (props: {
21
+ dense?: boolean | undefined;
22
+ variant?: _backstage_core_components.InfoCardVariants | undefined;
23
+ }) => react.JSX.Element;
24
+
25
+ /** @public */
26
+ declare const isLighthouseAvailable: (entity: Entity) => boolean;
27
+ /** @public */
28
+ declare const Router: () => react__default.JSX.Element;
29
+ /** @public */
30
+ declare const EmbeddedRouter: () => react__default.JSX.Element;
31
+
32
+ /** @public */
33
+ declare const lighthouseApiRef: _backstage_core_plugin_api.ApiRef<LighthouseApi>;
34
+
35
+ /** @public */
36
+ declare const LastLighthouseAuditCard: (props: {
37
+ dense?: boolean;
38
+ variant?: InfoCardVariants;
39
+ }) => react__default.JSX.Element;
40
+
41
+ export { EmbeddedRouter, EntityLastLighthouseAuditCard, EntityLighthouseContent, LastLighthouseAuditCard, LighthousePage, Router, isLighthouseAvailable, isLighthouseAvailable as isPluginApplicableToEntity, lighthouseApiRef, lighthousePlugin, lighthousePlugin as plugin };