@backstage-community/plugin-lighthouse 0.4.20 → 0.4.21

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/Router.esm.js +26 -0
  3. package/dist/Router.esm.js.map +1 -0
  4. package/dist/api.esm.js +8 -0
  5. package/dist/api.esm.js.map +1 -0
  6. package/dist/components/AuditList/AuditListForEntity.esm.js +43 -0
  7. package/dist/components/AuditList/AuditListForEntity.esm.js.map +1 -0
  8. package/dist/components/AuditList/AuditListTable.esm.js +92 -0
  9. package/dist/components/AuditList/AuditListTable.esm.js.map +1 -0
  10. package/dist/components/AuditList/index.esm.js +83 -0
  11. package/dist/components/AuditList/index.esm.js.map +1 -0
  12. package/dist/components/AuditStatusIcon/index.esm.js +11 -0
  13. package/dist/components/AuditStatusIcon/index.esm.js.map +1 -0
  14. package/dist/components/AuditView/index.esm.js +135 -0
  15. package/dist/components/AuditView/index.esm.js.map +1 -0
  16. package/dist/components/Cards/LastLighthouseAuditCard.esm.js +57 -0
  17. package/dist/components/Cards/LastLighthouseAuditCard.esm.js.map +1 -0
  18. package/dist/components/Cards/index.esm.js +2 -0
  19. package/dist/components/Cards/index.esm.js.map +1 -0
  20. package/dist/components/CreateAudit/index.esm.js +152 -0
  21. package/dist/components/CreateAudit/index.esm.js.map +1 -0
  22. package/dist/components/Intro/index.esm.js +130 -0
  23. package/dist/components/Intro/index.esm.js.map +1 -0
  24. package/dist/components/SupportButton/index.esm.js +9 -0
  25. package/dist/components/SupportButton/index.esm.js.map +1 -0
  26. package/dist/constants.esm.js +4 -0
  27. package/dist/constants.esm.js.map +1 -0
  28. package/dist/hooks/useWebsiteForEntity.esm.js +23 -0
  29. package/dist/hooks/useWebsiteForEntity.esm.js.map +1 -0
  30. package/dist/index.esm.js +4 -770
  31. package/dist/index.esm.js.map +1 -1
  32. package/dist/plugin.esm.js +55 -0
  33. package/dist/plugin.esm.js.map +1 -0
  34. package/dist/utils.esm.js +44 -0
  35. package/dist/utils.esm.js.map +1 -0
  36. package/package.json +17 -11
  37. package/dist/esm/index-DTZMI_cR.esm.js +0 -26
  38. package/dist/esm/index-DTZMI_cR.esm.js.map +0 -1
@@ -0,0 +1,152 @@
1
+ import Button from '@material-ui/core/Button';
2
+ import Grid from '@material-ui/core/Grid';
3
+ import List from '@material-ui/core/List';
4
+ import ListItem from '@material-ui/core/ListItem';
5
+ import MenuItem from '@material-ui/core/MenuItem';
6
+ import TextField from '@material-ui/core/TextField';
7
+ import { makeStyles } from '@material-ui/core/styles';
8
+ import React, { useState, useCallback } from 'react';
9
+ import { useNavigate } from 'react-router-dom';
10
+ import { lighthouseApiRef } from '../../api.esm.js';
11
+ import { useQuery } from '../../utils.esm.js';
12
+ import LighthouseSupportButton from '../SupportButton/index.esm.js';
13
+ import { ContentHeader, InfoCard, Page, Header, HeaderLabel, Content } from '@backstage/core-components';
14
+ import { useApi, errorApiRef } from '@backstage/core-plugin-api';
15
+
16
+ const useStyles = makeStyles((theme) => ({
17
+ input: {
18
+ minWidth: 300,
19
+ [theme.breakpoints.down("xs")]: {
20
+ minWidth: "100%"
21
+ }
22
+ },
23
+ buttonList: {
24
+ marginLeft: theme.spacing(-1),
25
+ marginRight: theme.spacing(-1),
26
+ "& > *": {
27
+ margin: theme.spacing(1)
28
+ },
29
+ [theme.breakpoints.down("xs")]: {
30
+ marginLeft: 0,
31
+ marginRight: 0,
32
+ flexDirection: "column",
33
+ "& > *": {
34
+ width: "100%"
35
+ }
36
+ }
37
+ }
38
+ }));
39
+ const formFactorToScreenEmulationMap = {
40
+ // the default is mobile, so no need to override
41
+ mobile: void 0,
42
+ // Values from lighthouse's cli "desktop" preset
43
+ // https://github.com/GoogleChrome/lighthouse/blob/a6738e0033e7e5ca308b97c1c36f298b7d399402/lighthouse-core/config/constants.js#L71-L77
44
+ desktop: {
45
+ mobile: false,
46
+ width: 1350,
47
+ height: 940,
48
+ deviceScaleFactor: 1,
49
+ disabled: false
50
+ }
51
+ };
52
+ const CreateAuditContent = () => {
53
+ const errorApi = useApi(errorApiRef);
54
+ const lighthouseApi = useApi(lighthouseApiRef);
55
+ const classes = useStyles();
56
+ const query = useQuery();
57
+ const navigate = useNavigate();
58
+ const [submitting, setSubmitting] = useState(false);
59
+ const [url, setUrl] = useState(query.get("url") || "");
60
+ const [formFactor, setFormFactor] = useState("mobile");
61
+ const triggerAudit = useCallback(async () => {
62
+ setSubmitting(true);
63
+ try {
64
+ await lighthouseApi.triggerAudit({
65
+ url: url.replace(/\/$/, ""),
66
+ options: {
67
+ lighthouseConfig: {
68
+ settings: {
69
+ formFactor,
70
+ emulatedFormFactor: formFactor,
71
+ screenEmulation: formFactorToScreenEmulationMap[formFactor]
72
+ }
73
+ }
74
+ }
75
+ });
76
+ navigate("..");
77
+ } catch (err) {
78
+ errorApi.post(err);
79
+ } finally {
80
+ setSubmitting(false);
81
+ }
82
+ }, [url, formFactor, lighthouseApi, setSubmitting, errorApi, navigate]);
83
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
84
+ ContentHeader,
85
+ {
86
+ title: "Trigger a new audit",
87
+ description: "Submitting this form will immediately trigger and store a new Lighthouse audit. Trigger audits to track your website's accessibility, performance, SEO, and best practices over time."
88
+ },
89
+ /* @__PURE__ */ React.createElement(LighthouseSupportButton, null)
90
+ ), /* @__PURE__ */ React.createElement(Grid, { container: true, direction: "column" }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, sm: 6 }, /* @__PURE__ */ React.createElement(InfoCard, null, /* @__PURE__ */ React.createElement(
91
+ "form",
92
+ {
93
+ onSubmit: (ev) => {
94
+ ev.preventDefault();
95
+ triggerAudit();
96
+ }
97
+ },
98
+ /* @__PURE__ */ React.createElement(List, null, /* @__PURE__ */ React.createElement(ListItem, null, /* @__PURE__ */ React.createElement(
99
+ TextField,
100
+ {
101
+ name: "lighthouse-create-audit-url-tf",
102
+ className: classes.input,
103
+ label: "URL",
104
+ placeholder: "https://spotify.com",
105
+ helperText: "The target URL for Lighthouse to use.",
106
+ required: true,
107
+ disabled: submitting,
108
+ onChange: (ev) => setUrl(ev.target.value),
109
+ value: url,
110
+ inputProps: { "aria-label": "URL" }
111
+ }
112
+ )), /* @__PURE__ */ React.createElement(ListItem, null, /* @__PURE__ */ React.createElement(
113
+ TextField,
114
+ {
115
+ name: "lighthouse-create-audit-emulated-form-factor-tf",
116
+ className: classes.input,
117
+ label: "Emulated Form Factor",
118
+ helperText: "Device to simulate when auditing",
119
+ select: true,
120
+ required: true,
121
+ disabled: submitting,
122
+ onChange: (ev) => setFormFactor(ev.target.value),
123
+ value: formFactor,
124
+ inputProps: { "aria-label": "Emulated form factor" }
125
+ },
126
+ /* @__PURE__ */ React.createElement(MenuItem, { value: "mobile" }, "Mobile"),
127
+ /* @__PURE__ */ React.createElement(MenuItem, { value: "desktop" }, "Desktop")
128
+ )), /* @__PURE__ */ React.createElement(ListItem, { className: classes.buttonList }, /* @__PURE__ */ React.createElement(
129
+ Button,
130
+ {
131
+ variant: "outlined",
132
+ color: "primary",
133
+ onClick: () => navigate(".."),
134
+ disabled: submitting
135
+ },
136
+ "Cancel"
137
+ ), /* @__PURE__ */ React.createElement(
138
+ Button,
139
+ {
140
+ variant: "contained",
141
+ color: "primary",
142
+ type: "submit",
143
+ disabled: submitting
144
+ },
145
+ "Create Audit"
146
+ )))
147
+ )))));
148
+ };
149
+ const CreateAudit = () => /* @__PURE__ */ React.createElement(Page, { themeId: "tool" }, /* @__PURE__ */ React.createElement(Header, { title: "Lighthouse", subtitle: "Website audits powered by Lighthouse" }, /* @__PURE__ */ React.createElement(HeaderLabel, { label: "Owner", value: "Spotify" }), /* @__PURE__ */ React.createElement(HeaderLabel, { label: "Lifecycle", value: "Alpha" })), /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(CreateAuditContent, null)));
150
+
151
+ export { CreateAuditContent, CreateAudit as default };
152
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../../../src/components/CreateAudit/index.tsx"],"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 Button from '@material-ui/core/Button';\nimport Grid from '@material-ui/core/Grid';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport TextField from '@material-ui/core/TextField';\nimport { makeStyles } from '@material-ui/core/styles';\nimport React, { useCallback, useState } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport {\n FormFactor,\n LighthouseConfigSettings,\n} from '@backstage-community/plugin-lighthouse-common';\nimport { lighthouseApiRef } from '../../api';\nimport { useQuery } from '../../utils';\nimport LighthouseSupportButton from '../SupportButton';\n\nimport {\n Content,\n ContentHeader,\n Header,\n HeaderLabel,\n InfoCard,\n Page,\n} from '@backstage/core-components';\nimport { errorApiRef, useApi } from '@backstage/core-plugin-api';\n\n// TODO(freben): move all of this out of index\n\nconst useStyles = makeStyles(theme => ({\n input: {\n minWidth: 300,\n [theme.breakpoints.down('xs')]: {\n minWidth: '100%',\n },\n },\n buttonList: {\n marginLeft: theme.spacing(-1),\n marginRight: theme.spacing(-1),\n '& > *': {\n margin: theme.spacing(1),\n },\n [theme.breakpoints.down('xs')]: {\n marginLeft: 0,\n marginRight: 0,\n flexDirection: 'column',\n '& > *': {\n width: '100%',\n },\n },\n },\n}));\n\nconst formFactorToScreenEmulationMap: Record<\n FormFactor,\n LighthouseConfigSettings['screenEmulation']\n> = {\n // the default is mobile, so no need to override\n mobile: undefined,\n // Values from lighthouse's cli \"desktop\" preset\n // https://github.com/GoogleChrome/lighthouse/blob/a6738e0033e7e5ca308b97c1c36f298b7d399402/lighthouse-core/config/constants.js#L71-L77\n desktop: {\n mobile: false,\n width: 1350,\n height: 940,\n deviceScaleFactor: 1,\n disabled: false,\n },\n};\n\nexport const CreateAuditContent = () => {\n const errorApi = useApi(errorApiRef);\n const lighthouseApi = useApi(lighthouseApiRef);\n const classes = useStyles();\n const query = useQuery();\n const navigate = useNavigate();\n const [submitting, setSubmitting] = useState(false);\n const [url, setUrl] = useState<string>(query.get('url') || '');\n const [formFactor, setFormFactor] = useState<FormFactor>('mobile');\n\n const triggerAudit = useCallback(async (): Promise<void> => {\n setSubmitting(true);\n try {\n // TODO use the id from the response to redirect to the audit page for that id when\n // FAILED and RUNNING audits are supported\n await lighthouseApi.triggerAudit({\n url: url.replace(/\\/$/, ''),\n options: {\n lighthouseConfig: {\n settings: {\n formFactor,\n emulatedFormFactor: formFactor,\n screenEmulation: formFactorToScreenEmulationMap[formFactor],\n },\n },\n },\n });\n navigate('..');\n } catch (err) {\n errorApi.post(err);\n } finally {\n setSubmitting(false);\n }\n }, [url, formFactor, lighthouseApi, setSubmitting, errorApi, navigate]);\n\n return (\n <>\n <ContentHeader\n title=\"Trigger a new audit\"\n description=\"Submitting this form will immediately trigger and store a new Lighthouse audit. Trigger audits to track your website's accessibility, performance, SEO, and best practices over time.\"\n >\n <LighthouseSupportButton />\n </ContentHeader>\n <Grid container direction=\"column\">\n <Grid item xs={12} sm={6}>\n <InfoCard>\n <form\n onSubmit={ev => {\n ev.preventDefault();\n triggerAudit();\n }}\n >\n <List>\n <ListItem>\n <TextField\n name=\"lighthouse-create-audit-url-tf\"\n className={classes.input}\n label=\"URL\"\n placeholder=\"https://spotify.com\"\n helperText=\"The target URL for Lighthouse to use.\"\n required\n disabled={submitting}\n onChange={ev => setUrl(ev.target.value)}\n value={url}\n inputProps={{ 'aria-label': 'URL' }}\n />\n </ListItem>\n <ListItem>\n <TextField\n name=\"lighthouse-create-audit-emulated-form-factor-tf\"\n className={classes.input}\n label=\"Emulated Form Factor\"\n helperText=\"Device to simulate when auditing\"\n select\n required\n disabled={submitting}\n onChange={ev =>\n setFormFactor(ev.target.value as FormFactor)\n }\n value={formFactor}\n inputProps={{ 'aria-label': 'Emulated form factor' }}\n >\n <MenuItem value=\"mobile\">Mobile</MenuItem>\n <MenuItem value=\"desktop\">Desktop</MenuItem>\n </TextField>\n </ListItem>\n <ListItem className={classes.buttonList}>\n <Button\n variant=\"outlined\"\n color=\"primary\"\n onClick={() => navigate('..')}\n disabled={submitting}\n >\n Cancel\n </Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n type=\"submit\"\n disabled={submitting}\n >\n Create Audit\n </Button>\n </ListItem>\n </List>\n </form>\n </InfoCard>\n </Grid>\n </Grid>\n </>\n );\n};\n\nconst CreateAudit = () => (\n <Page themeId=\"tool\">\n <Header title=\"Lighthouse\" subtitle=\"Website audits powered by Lighthouse\">\n <HeaderLabel label=\"Owner\" value=\"Spotify\" />\n <HeaderLabel label=\"Lifecycle\" value=\"Alpha\" />\n </Header>\n <Content>\n <CreateAuditContent />\n </Content>\n </Page>\n);\n\nexport default CreateAudit;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA6CA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,KAAO,EAAA;AAAA,IACL,QAAU,EAAA,GAAA;AAAA,IACV,CAAC,KAAM,CAAA,WAAA,CAAY,IAAK,CAAA,IAAI,CAAC,GAAG;AAAA,MAC9B,QAAU,EAAA,MAAA;AAAA,KACZ;AAAA,GACF;AAAA,EACA,UAAY,EAAA;AAAA,IACV,UAAA,EAAY,KAAM,CAAA,OAAA,CAAQ,CAAE,CAAA,CAAA;AAAA,IAC5B,WAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,CAAE,CAAA,CAAA;AAAA,IAC7B,OAAS,EAAA;AAAA,MAC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mB,CACtB,CACF;;;;"}
@@ -0,0 +1,130 @@
1
+ import Button from '@material-ui/core/Button';
2
+ import Grid from '@material-ui/core/Grid';
3
+ import Tab from '@material-ui/core/Tab';
4
+ import Tabs from '@material-ui/core/Tabs';
5
+ import { makeStyles } from '@material-ui/core/styles';
6
+ import CloseIcon from '@material-ui/icons/Close';
7
+ import React, { useState } from 'react';
8
+ import useLocalStorage from 'react-use/esm/useLocalStorage';
9
+ import LighthouseSupportButton from '../SupportButton/index.esm.js';
10
+ import { ContentHeader, InfoCard, Link, MarkdownContent } from '@backstage/core-components';
11
+
12
+ const LIGHTHOUSE_INTRO_LOCAL_STORAGE = "@backstage/lighthouse-plugin/intro-dismissed";
13
+ const USE_CASES = `
14
+ Google's [Lighthouse](https://developers.google.com/web/tools/lighthouse) auditing tool for websites
15
+ is a great open-source resource for benchmarking and improving the accessibility, performance, SEO, and best practices of your site.
16
+ At Spotify, we keep track of Lighthouse audit scores over time to look at trends and overall areas for investment.
17
+
18
+ This plugin allows you to generate on-demand Lighthouse audits for websites, and to track the trends for the
19
+ top-level categories of Lighthouse at a glance.
20
+
21
+ In the future, we hope to add support for scheduling audits (which we do internally), as well as allowing
22
+ custom runs of Lighthouse to be ingested (for auditing sites that require authentication or some session state).
23
+ `;
24
+ const SETUP = `
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 when running lighthouse-audit-service. Initialize the app
27
+ with the environment variable \`LAS_CORS\` set to \`true\`._
28
+
29
+ When you have an instance running that Backstage can hook into, first install the plugin into your app:
30
+
31
+ \`\`\`sh
32
+ # From your Backstage root directory
33
+ yarn --cwd packages/app add @backstage-community/plugin-lighthouse
34
+ \`\`\`
35
+
36
+ Modify your app routes in \`App.tsx\` to include the \`LighthousePage\` component exported from the plugin, for example:
37
+
38
+ \`\`\`tsx
39
+ // At the top imports
40
+ import { LighthousePage } from '@backstage-community/plugin-lighthouse';
41
+
42
+ <FlatRoutes>
43
+ // ...
44
+ <Route path="/lighthouse" element={<LighthousePage />} />
45
+ // ...
46
+ </FlatRoutes>;
47
+ \`\`\`
48
+
49
+ Then configure the \`lighthouse-audit-service\` URL in your [\`app-config.yaml\`](https://github.com/backstage/backstage/blob/master/app-config.yaml).
50
+
51
+ \`\`\`yaml
52
+ lighthouse:
53
+ baseUrl: http://your-service-url
54
+ \`\`\`
55
+ `;
56
+ const useStyles = makeStyles((theme) => ({
57
+ tabs: { marginBottom: -18 },
58
+ tab: { minWidth: 72, paddingLeft: 1, paddingRight: 1 },
59
+ content: { marginBottom: theme.spacing(2) },
60
+ closeButtonContainer: { height: "100%" },
61
+ closeButtonItem: { paddingBottom: 0 }
62
+ }));
63
+ function GettingStartedCard() {
64
+ const classes = useStyles();
65
+ const [value, setValue] = useState(0);
66
+ return /* @__PURE__ */ React.createElement(
67
+ InfoCard,
68
+ {
69
+ title: "Get started",
70
+ subheader: /* @__PURE__ */ React.createElement(
71
+ Tabs,
72
+ {
73
+ value,
74
+ indicatorColor: "primary",
75
+ textColor: "primary",
76
+ onChange: (_ev, newValue) => setValue(newValue),
77
+ "aria-label": "get started tabs",
78
+ className: classes.tabs
79
+ },
80
+ /* @__PURE__ */ React.createElement(Tab, { className: classes.tab, label: "Use cases" }),
81
+ /* @__PURE__ */ React.createElement(Tab, { className: classes.tab, label: "Setup" })
82
+ ),
83
+ divider: true,
84
+ actions: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Grid, { container: true, direction: "row", justifyContent: "flex-end" }, /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(
85
+ Button,
86
+ {
87
+ component: Link,
88
+ to: "https://github.com/spotify/lighthouse-audit-service",
89
+ size: "small"
90
+ },
91
+ "Check out the README"
92
+ ))))
93
+ },
94
+ value === 0 && /* @__PURE__ */ React.createElement(MarkdownContent, { content: USE_CASES }),
95
+ value === 1 && /* @__PURE__ */ React.createElement(MarkdownContent, { content: SETUP })
96
+ );
97
+ }
98
+ function LighthouseIntro({ onDismiss = () => {
99
+ } }) {
100
+ const classes = useStyles();
101
+ const [dismissed, setDismissed] = useLocalStorage(
102
+ LIGHTHOUSE_INTRO_LOCAL_STORAGE,
103
+ false
104
+ );
105
+ if (dismissed) return null;
106
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ContentHeader, { title: "Welcome to Lighthouse in Backstage!" }, /* @__PURE__ */ React.createElement(LighthouseSupportButton, null)), /* @__PURE__ */ React.createElement(Grid, { className: classes.content, container: true, spacing: 3, direction: "row" }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, sm: 6, md: 4 }, /* @__PURE__ */ React.createElement(GettingStartedCard, null)), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, sm: 6, md: 8 }, /* @__PURE__ */ React.createElement(
107
+ Grid,
108
+ {
109
+ container: true,
110
+ justifyContent: "flex-end",
111
+ alignItems: "flex-end",
112
+ className: classes.closeButtonContainer
113
+ },
114
+ /* @__PURE__ */ React.createElement(Grid, { item: true, className: classes.closeButtonItem }, /* @__PURE__ */ React.createElement(
115
+ Button,
116
+ {
117
+ variant: "text",
118
+ onClick: () => {
119
+ onDismiss();
120
+ setDismissed(true);
121
+ }
122
+ },
123
+ /* @__PURE__ */ React.createElement(CloseIcon, null),
124
+ " Hide intro"
125
+ ))
126
+ ))));
127
+ }
128
+
129
+ export { LIGHTHOUSE_INTRO_LOCAL_STORAGE, LighthouseIntro as default };
130
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../../../src/components/Intro/index.tsx"],"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 Button from '@material-ui/core/Button';\nimport Grid from '@material-ui/core/Grid';\nimport Tab from '@material-ui/core/Tab';\nimport Tabs from '@material-ui/core/Tabs';\nimport { makeStyles } from '@material-ui/core/styles';\nimport CloseIcon from '@material-ui/icons/Close';\nimport React, { useState } from 'react';\nimport useLocalStorage from 'react-use/esm/useLocalStorage';\nimport LighthouseSupportButton from '../SupportButton';\nimport {\n ContentHeader,\n InfoCard,\n Link,\n MarkdownContent,\n} from '@backstage/core-components';\n\n// TODO(freben): move all of this out of index\n\nexport const LIGHTHOUSE_INTRO_LOCAL_STORAGE =\n '@backstage/lighthouse-plugin/intro-dismissed';\n\nconst USE_CASES = `\nGoogle's [Lighthouse](https://developers.google.com/web/tools/lighthouse) auditing tool for websites\nis a great open-source resource for benchmarking and improving the accessibility, performance, SEO, and best practices of your site.\nAt Spotify, we keep track of Lighthouse audit scores over time to look at trends and overall areas for investment.\n\nThis plugin allows you to generate on-demand Lighthouse audits for websites, and to track the trends for the\ntop-level categories of Lighthouse at a glance.\n\nIn the future, we hope to add support for scheduling audits (which we do internally), as well as allowing\ncustom runs of Lighthouse to be ingested (for auditing sites that require authentication or some session state).\n`;\n\nconst SETUP = `\nTo get started, you will need a running instance of [lighthouse-audit-service](https://github.com/spotify/lighthouse-audit-service).\n_It's likely you will need to enable CORS when running lighthouse-audit-service. Initialize the app\nwith the environment variable \\`LAS_CORS\\` set to \\`true\\`._\n\nWhen you have an instance running that Backstage can hook into, first install the plugin into your app:\n\n\\`\\`\\`sh\n# From your Backstage root directory\nyarn --cwd packages/app add @backstage-community/plugin-lighthouse\n\\`\\`\\`\n\nModify your app routes in \\`App.tsx\\` to include the \\`LighthousePage\\` component exported from the plugin, for example:\n\n\\`\\`\\`tsx\n// At the top imports\nimport { LighthousePage } from '@backstage-community/plugin-lighthouse';\n\n<FlatRoutes>\n // ...\n <Route path=\"/lighthouse\" element={<LighthousePage />} />\n // ...\n</FlatRoutes>;\n\\`\\`\\`\n\nThen configure the \\`lighthouse-audit-service\\` URL in your [\\`app-config.yaml\\`](https://github.com/backstage/backstage/blob/master/app-config.yaml).\n\n\\`\\`\\`yaml\nlighthouse:\n baseUrl: http://your-service-url\n\\`\\`\\`\n`;\n\nconst useStyles = makeStyles(theme => ({\n tabs: { marginBottom: -18 },\n tab: { minWidth: 72, paddingLeft: 1, paddingRight: 1 },\n content: { marginBottom: theme.spacing(2) },\n closeButtonContainer: { height: '100%' },\n closeButtonItem: { paddingBottom: 0 },\n}));\n\nfunction GettingStartedCard() {\n const classes = useStyles();\n const [value, setValue] = useState(0);\n return (\n <InfoCard\n title=\"Get started\"\n subheader={\n <Tabs\n value={value}\n indicatorColor=\"primary\"\n textColor=\"primary\"\n onChange={(_ev, newValue: number) => setValue(newValue)}\n aria-label=\"get started tabs\"\n className={classes.tabs}\n >\n <Tab className={classes.tab} label=\"Use cases\" />\n <Tab className={classes.tab} label=\"Setup\" />\n </Tabs>\n }\n divider\n actions={\n <>\n <Grid container direction=\"row\" justifyContent=\"flex-end\">\n <Grid item>\n <Button\n component={Link}\n to=\"https://github.com/spotify/lighthouse-audit-service\"\n size=\"small\"\n >\n Check out the README\n </Button>\n </Grid>\n </Grid>\n </>\n }\n >\n {value === 0 && <MarkdownContent content={USE_CASES} />}\n {value === 1 && <MarkdownContent content={SETUP} />}\n </InfoCard>\n );\n}\n\nexport interface Props {\n onDismiss?: () => void;\n}\n\nexport default function LighthouseIntro({ onDismiss = () => {} }: Props) {\n const classes = useStyles();\n const [dismissed, setDismissed] = useLocalStorage(\n LIGHTHOUSE_INTRO_LOCAL_STORAGE,\n false,\n );\n\n if (dismissed) return null;\n\n return (\n <>\n <ContentHeader title=\"Welcome to Lighthouse in Backstage!\">\n <LighthouseSupportButton />\n </ContentHeader>\n <Grid className={classes.content} container spacing={3} direction=\"row\">\n <Grid item xs={12} sm={6} md={4}>\n <GettingStartedCard />\n </Grid>\n {/* TODO add link and image for blog post here */}\n {/* <Grid item xs={12} sm={6} md={4}>\n <InfoCard>Blog</InfoCard>\n </Grid> */}\n <Grid item xs={12} sm={6} md={8}>\n <Grid\n container\n justifyContent=\"flex-end\"\n alignItems=\"flex-end\"\n className={classes.closeButtonContainer}\n >\n <Grid item className={classes.closeButtonItem}>\n <Button\n variant=\"text\"\n onClick={() => {\n onDismiss();\n setDismissed(true);\n }}\n >\n <CloseIcon /> Hide intro\n </Button>\n </Grid>\n </Grid>\n </Grid>\n </Grid>\n </>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAkCO,MAAM,8BACX,GAAA,+CAAA;AAEF,MAAM,SAAY,GAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAAA;AAYlB,MAAM,KAAQ,GAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAAA;AAiCd,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,IAAA,EAAM,EAAE,YAAA,EAAc,CAAI,EAAA,EAAA;AAAA,EAC1B,KAAK,EAAE,QAAA,EAAU,IAAI,WAAa,EAAA,CAAA,EAAG,cAAc,CAAE,EAAA;AAAA,EACrD,SAAS,EAAE,YAAA,EAAc,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAE,EAAA;AAAA,EAC1C,oBAAA,EAAsB,EAAE,MAAA,EAAQ,MAAO,EAAA;AAAA,EACvC,eAAA,EAAiB,EAAE,aAAA,EAAe,CAAE,EAAA;AACtC,CAAE,CAAA,CAAA,CAAA;AAEF,SAAS,kBAAqB,GAAA;AAC5B,EAAA,MAAM,UAA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EAAA,EAAA,IAAA,EAAI,IAAC,EAAA,SAAA,EAAW,QAAQ,eAC5B,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,OAAQ,EAAA,MAAA;AAAA,QACR,SAAS,MAAM;AACb,UAAU,SAAA,EAAA,CAAA;AACV,UAAA,YAAA,CAAa,IAAI,CAAA,CAAA;AAAA,SACnB;AAAA,OAAA;AAAA,0CAEC,SAAU,EAAA,IAAA,CAAA;AAAA,MAAE,aAAA;AAAA,KAEjB,CAAA;AAAA,GAEJ,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { SupportButton } from '@backstage/core-components';
3
+
4
+ function LighthouseSupportButton() {
5
+ return /* @__PURE__ */ React.createElement(SupportButton, null, "Lighthouse audits run for any web domain, stored over time.");
6
+ }
7
+
8
+ export { LighthouseSupportButton as default };
9
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../../../src/components/SupportButton/index.tsx"],"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 */\nimport React from 'react';\nimport { SupportButton } from '@backstage/core-components';\n\nexport default function LighthouseSupportButton() {\n return (\n <SupportButton>\n Lighthouse audits run for any web domain, stored over time.\n </SupportButton>\n );\n}\n"],"names":[],"mappings":";;;AAkBA,SAAwB,uBAA0B,GAAA;AAChD,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,qBAAc,6DAEf,CAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,4 @@
1
+ const LIGHTHOUSE_WEBSITE_URL_ANNOTATION = "lighthouse.com/website-url";
2
+
3
+ export { LIGHTHOUSE_WEBSITE_URL_ANNOTATION };
4
+ //# sourceMappingURL=constants.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.esm.js","sources":["../constants.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 */\nexport const LIGHTHOUSE_WEBSITE_URL_ANNOTATION = 'lighthouse.com/website-url';\n"],"names":[],"mappings":"AAeO,MAAM,iCAAoC,GAAA;;;;"}
@@ -0,0 +1,23 @@
1
+ import { useEntity } from '@backstage/plugin-catalog-react';
2
+ import useAsync from 'react-use/esm/useAsync';
3
+ import { LIGHTHOUSE_WEBSITE_URL_ANNOTATION } from '../constants.esm.js';
4
+ import { lighthouseApiRef } from '../api.esm.js';
5
+ import { useApi, errorApiRef } from '@backstage/core-plugin-api';
6
+
7
+ const useWebsiteForEntity = () => {
8
+ const { entity } = useEntity();
9
+ const websiteUrl = entity.metadata.annotations?.[LIGHTHOUSE_WEBSITE_URL_ANNOTATION] ?? "";
10
+ const lighthouseApi = useApi(lighthouseApiRef);
11
+ const errorApi = useApi(errorApiRef);
12
+ const response = useAsync(
13
+ () => lighthouseApi.getWebsiteByUrl(websiteUrl),
14
+ [websiteUrl]
15
+ );
16
+ if (response.error && !response.error.message.includes("no audited website found for url")) {
17
+ errorApi.post(response.error);
18
+ }
19
+ return response;
20
+ };
21
+
22
+ export { useWebsiteForEntity };
23
+ //# sourceMappingURL=useWebsiteForEntity.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWebsiteForEntity.esm.js","sources":["../../src/hooks/useWebsiteForEntity.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 */\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { LIGHTHOUSE_WEBSITE_URL_ANNOTATION } from '../../constants';\nimport { lighthouseApiRef } from '../api';\nimport { errorApiRef, useApi } from '@backstage/core-plugin-api';\n\n// For the sake of simplicity we assume that an entity has only one website url. This is to avoid encoding a list\n// type in an annotation which is a plain string.\nexport const useWebsiteForEntity = () => {\n const { entity } = useEntity();\n const websiteUrl =\n entity.metadata.annotations?.[LIGHTHOUSE_WEBSITE_URL_ANNOTATION] ?? '';\n const lighthouseApi = useApi(lighthouseApiRef);\n const errorApi = useApi(errorApiRef);\n const response = useAsync(\n () => lighthouseApi.getWebsiteByUrl(websiteUrl),\n [websiteUrl],\n );\n // Do not display error alert if its due to no audits found for a website\n if (\n response.error &&\n !response.error.message.includes('no audited website found for url')\n ) {\n errorApi.post(response.error);\n }\n return response;\n};\n"],"names":[],"mappings":";;;;;;AAuBO,MAAM,sBAAsB,MAAM;AACvC,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA,CAAA;AAC7B,EAAA,MAAM,UACJ,GAAA,MAAA,CAAO,QAAS,CAAA,WAAA,GAAc,iCAAiC,CAAK,IAAA,EAAA,CAAA;AACtE,EAAM,MAAA,aAAA,GAAgB,OAAO,gBAAgB,CAAA,CAAA;AAC7C,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AACnC,EAAA,MAAM,QAAW,GAAA,QAAA;AAAA,IACf,MAAM,aAAc,CAAA,eAAA,CAAgB,UAAU,CAAA;AAAA,IAC9C,CAAC,UAAU,CAAA;AAAA,GACb,CAAA;AAEA,EACE,IAAA,QAAA,CAAS,SACT,CAAC,QAAA,CAAS,MAAM,OAAQ,CAAA,QAAA,CAAS,kCAAkC,CACnE,EAAA;AACA,IAAS,QAAA,CAAA,IAAA,CAAK,SAAS,KAAK,CAAA,CAAA;AAAA,GAC9B;AACA,EAAO,OAAA,QAAA,CAAA;AACT;;;;"}