@backstage-community/plugin-code-coverage 0.2.28 → 0.2.29
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 +7 -0
- package/dist/api.esm.js +48 -0
- package/dist/api.esm.js.map +1 -0
- package/dist/components/CodeCoveragePage/CodeCoveragePage.esm.js +11 -0
- package/dist/components/CodeCoveragePage/CodeCoveragePage.esm.js.map +1 -0
- package/dist/components/CoverageHistoryChart/CoverageHistoryChart.esm.js +112 -0
- package/dist/components/CoverageHistoryChart/CoverageHistoryChart.esm.js.map +1 -0
- package/dist/components/FileExplorer/CodeRow.esm.js +78 -0
- package/dist/components/FileExplorer/CodeRow.esm.js.map +1 -0
- package/dist/components/FileExplorer/FileContent.esm.js +89 -0
- package/dist/components/FileExplorer/FileContent.esm.js.map +1 -0
- package/dist/components/FileExplorer/FileExplorer.esm.js +239 -0
- package/dist/components/FileExplorer/FileExplorer.esm.js.map +1 -0
- package/dist/components/FileExplorer/Highlighter.esm.js +30 -0
- package/dist/components/FileExplorer/Highlighter.esm.js.map +1 -0
- package/dist/components/Router.esm.js +17 -0
- package/dist/components/Router.esm.js.map +1 -0
- package/dist/index.esm.js +3 -618
- package/dist/index.esm.js.map +1 -1
- package/dist/plugin.esm.js +27 -0
- package/dist/plugin.esm.js.map +1 -0
- package/dist/routes.esm.js +8 -0
- package/dist/routes.esm.js.map +1 -0
- package/package.json +14 -9
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { useEntity, humanizeEntityRef } from '@backstage/plugin-catalog-react';
|
|
2
|
+
import Box from '@material-ui/core/Box';
|
|
3
|
+
import Modal from '@material-ui/core/Modal';
|
|
4
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
5
|
+
import FolderIcon from '@material-ui/icons/Folder';
|
|
6
|
+
import FileOutlinedIcon from '@material-ui/icons/InsertDriveFileOutlined';
|
|
7
|
+
import Alert from '@material-ui/lab/Alert';
|
|
8
|
+
import React, { useState, useEffect, Fragment } from 'react';
|
|
9
|
+
import useAsync from 'react-use/esm/useAsync';
|
|
10
|
+
import { codeCoverageApiRef } from '../../api.esm.js';
|
|
11
|
+
import { FileContent } from './FileContent.esm.js';
|
|
12
|
+
import { Progress, ResponseErrorPanel, Table } from '@backstage/core-components';
|
|
13
|
+
import { useApi } from '@backstage/core-plugin-api';
|
|
14
|
+
|
|
15
|
+
const useStyles = makeStyles((theme) => ({
|
|
16
|
+
container: {
|
|
17
|
+
marginTop: theme.spacing(2)
|
|
18
|
+
},
|
|
19
|
+
icon: {
|
|
20
|
+
marginRight: theme.spacing(1)
|
|
21
|
+
},
|
|
22
|
+
link: {
|
|
23
|
+
color: theme.palette.primary.main,
|
|
24
|
+
cursor: "pointer"
|
|
25
|
+
}
|
|
26
|
+
}));
|
|
27
|
+
const groupByPath = (files) => {
|
|
28
|
+
const acc = {};
|
|
29
|
+
files.forEach((file) => {
|
|
30
|
+
const filename = file.filename;
|
|
31
|
+
if (!file.filename) return;
|
|
32
|
+
const pathArray = filename?.split("/").filter((el) => el !== "");
|
|
33
|
+
if (pathArray) {
|
|
34
|
+
if (!acc.hasOwnProperty(pathArray[0])) {
|
|
35
|
+
acc[pathArray[0]] = [];
|
|
36
|
+
}
|
|
37
|
+
acc[pathArray[0]].push(file);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return acc;
|
|
41
|
+
};
|
|
42
|
+
const removeVisitedPathGroup = (files, pathGroup) => {
|
|
43
|
+
return files.map((file) => {
|
|
44
|
+
return {
|
|
45
|
+
...file,
|
|
46
|
+
filename: file.filename ? file.filename.substring(
|
|
47
|
+
file.filename?.indexOf(pathGroup) + pathGroup.length + 1
|
|
48
|
+
) : file.filename
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const buildFileStructure = (row) => {
|
|
53
|
+
const dataGroupedByPath = groupByPath(row.files);
|
|
54
|
+
row.files = Object.keys(dataGroupedByPath).map((pathGroup) => {
|
|
55
|
+
return buildFileStructure({
|
|
56
|
+
path: pathGroup,
|
|
57
|
+
files: dataGroupedByPath.hasOwnProperty("files") ? removeVisitedPathGroup(dataGroupedByPath.files, pathGroup) : removeVisitedPathGroup(dataGroupedByPath[pathGroup], pathGroup),
|
|
58
|
+
coverage: dataGroupedByPath[pathGroup].reduce(
|
|
59
|
+
(acc, cur) => acc + cur.coverage,
|
|
60
|
+
0
|
|
61
|
+
) / dataGroupedByPath[pathGroup].length,
|
|
62
|
+
missing: dataGroupedByPath[pathGroup].reduce(
|
|
63
|
+
(acc, cur) => acc + cur.missing,
|
|
64
|
+
0
|
|
65
|
+
),
|
|
66
|
+
tracked: dataGroupedByPath[pathGroup].reduce(
|
|
67
|
+
(acc, cur) => acc + cur.tracked,
|
|
68
|
+
0
|
|
69
|
+
)
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
return row;
|
|
73
|
+
};
|
|
74
|
+
const formatInitialData = (value) => {
|
|
75
|
+
return buildFileStructure({
|
|
76
|
+
path: "",
|
|
77
|
+
coverage: value.aggregate.line.percentage,
|
|
78
|
+
missing: value.aggregate.line.missed,
|
|
79
|
+
tracked: value.aggregate.line.available,
|
|
80
|
+
files: value.files.map((fc) => {
|
|
81
|
+
return {
|
|
82
|
+
path: "",
|
|
83
|
+
filename: fc.filename,
|
|
84
|
+
coverage: Math.floor(
|
|
85
|
+
Object.values(fc.lineHits).filter((hits) => hits > 0).length / Object.values(fc.lineHits).length * 100
|
|
86
|
+
),
|
|
87
|
+
missing: Object.values(fc.lineHits).filter((hits) => !hits).length,
|
|
88
|
+
tracked: Object.values(fc.lineHits).length
|
|
89
|
+
};
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
const getObjectsAtPath = (curData, path) => {
|
|
94
|
+
let data = curData?.files;
|
|
95
|
+
for (const fragment of path) {
|
|
96
|
+
data = data?.find((d) => d.path === fragment)?.files;
|
|
97
|
+
}
|
|
98
|
+
return data;
|
|
99
|
+
};
|
|
100
|
+
const FileExplorer = () => {
|
|
101
|
+
const styles = useStyles();
|
|
102
|
+
const { entity } = useEntity();
|
|
103
|
+
const [curData, setCurData] = useState();
|
|
104
|
+
const [tableData, setTableData] = useState();
|
|
105
|
+
const [curPath, setCurPath] = useState("");
|
|
106
|
+
const [modalOpen, setModalOpen] = useState(false);
|
|
107
|
+
const [curFile, setCurFile] = useState("");
|
|
108
|
+
const codeCoverageApi = useApi(codeCoverageApiRef);
|
|
109
|
+
const { loading, error, value } = useAsync(
|
|
110
|
+
async () => await codeCoverageApi.getCoverageForEntity({
|
|
111
|
+
kind: entity.kind,
|
|
112
|
+
namespace: entity.metadata.namespace || "default",
|
|
113
|
+
name: entity.metadata.name
|
|
114
|
+
})
|
|
115
|
+
);
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (!value) return;
|
|
118
|
+
const data = formatInitialData(value);
|
|
119
|
+
setCurData(data);
|
|
120
|
+
if (data.files) setTableData(data.files);
|
|
121
|
+
}, [value]);
|
|
122
|
+
if (loading) {
|
|
123
|
+
return /* @__PURE__ */ React.createElement(Progress, null);
|
|
124
|
+
} else if (error) {
|
|
125
|
+
return /* @__PURE__ */ React.createElement(ResponseErrorPanel, { error });
|
|
126
|
+
}
|
|
127
|
+
if (!value) {
|
|
128
|
+
return /* @__PURE__ */ React.createElement(Alert, { severity: "warning" }, "No code coverage found for ", humanizeEntityRef(entity));
|
|
129
|
+
}
|
|
130
|
+
const moveDownIntoPath = (path) => {
|
|
131
|
+
const nextPathData = tableData.find(
|
|
132
|
+
(d) => d.path === path
|
|
133
|
+
);
|
|
134
|
+
if (nextPathData && nextPathData.files) {
|
|
135
|
+
setTableData(nextPathData.files);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const moveUpIntoPath = (idx) => {
|
|
139
|
+
const path = curPath.split("/").slice(0, idx + 1);
|
|
140
|
+
setCurFile("");
|
|
141
|
+
setCurPath(path.join("/"));
|
|
142
|
+
setTableData(getObjectsAtPath(curData, path.slice(1)));
|
|
143
|
+
};
|
|
144
|
+
const columns = [
|
|
145
|
+
{
|
|
146
|
+
title: "Path",
|
|
147
|
+
type: "string",
|
|
148
|
+
field: "path",
|
|
149
|
+
render: (row) => /* @__PURE__ */ React.createElement(
|
|
150
|
+
Box,
|
|
151
|
+
{
|
|
152
|
+
display: "flex",
|
|
153
|
+
alignItems: "center",
|
|
154
|
+
role: "button",
|
|
155
|
+
tabIndex: row.tableData.id,
|
|
156
|
+
className: styles.link,
|
|
157
|
+
onClick: () => {
|
|
158
|
+
if (row.files?.length) {
|
|
159
|
+
setCurPath(`${curPath}/${row.path}`);
|
|
160
|
+
moveDownIntoPath(row.path);
|
|
161
|
+
} else {
|
|
162
|
+
setCurFile(`${curPath.slice(1)}/${row.path}`);
|
|
163
|
+
setModalOpen(true);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
row.files?.length > 0 && /* @__PURE__ */ React.createElement(FolderIcon, { fontSize: "small", className: styles.icon }),
|
|
168
|
+
row.files?.length === 0 && /* @__PURE__ */ React.createElement(FileOutlinedIcon, { fontSize: "small", className: styles.icon }),
|
|
169
|
+
row.path
|
|
170
|
+
)
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
title: "Coverage",
|
|
174
|
+
type: "numeric",
|
|
175
|
+
field: "coverage",
|
|
176
|
+
render: (row) => `${row.coverage.toFixed(2)}%`
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
title: "Missing lines",
|
|
180
|
+
type: "numeric",
|
|
181
|
+
field: "missing"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
title: "Tracked lines",
|
|
185
|
+
type: "numeric",
|
|
186
|
+
field: "tracked"
|
|
187
|
+
}
|
|
188
|
+
];
|
|
189
|
+
const pathArray = curPath.split("/");
|
|
190
|
+
const lastPathElementIndex = pathArray.length - 1;
|
|
191
|
+
const fileCoverage = value.files.find(
|
|
192
|
+
(f) => f.filename.endsWith(curFile)
|
|
193
|
+
);
|
|
194
|
+
if (!fileCoverage) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
return /* @__PURE__ */ React.createElement(Box, { className: styles.container }, /* @__PURE__ */ React.createElement(
|
|
198
|
+
Table,
|
|
199
|
+
{
|
|
200
|
+
emptyContent: /* @__PURE__ */ React.createElement(React.Fragment, null, "No files found"),
|
|
201
|
+
data: tableData || [],
|
|
202
|
+
columns,
|
|
203
|
+
title: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Box, null, "Explore Files"), /* @__PURE__ */ React.createElement(
|
|
204
|
+
Box,
|
|
205
|
+
{
|
|
206
|
+
mt: 1,
|
|
207
|
+
style: {
|
|
208
|
+
fontSize: "0.875rem",
|
|
209
|
+
fontWeight: "normal",
|
|
210
|
+
display: "flex"
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
pathArray.map((pathElement, idx) => /* @__PURE__ */ React.createElement(Fragment, { key: pathElement || "root" }, /* @__PURE__ */ React.createElement(
|
|
214
|
+
"div",
|
|
215
|
+
{
|
|
216
|
+
role: "button",
|
|
217
|
+
tabIndex: idx,
|
|
218
|
+
className: idx !== lastPathElementIndex ? styles.link : void 0,
|
|
219
|
+
onKeyDown: () => moveUpIntoPath(idx),
|
|
220
|
+
onClick: () => moveUpIntoPath(idx)
|
|
221
|
+
},
|
|
222
|
+
pathElement || "root"
|
|
223
|
+
), idx !== lastPathElementIndex && /* @__PURE__ */ React.createElement("div", null, "\xA0/\xA0")))
|
|
224
|
+
))
|
|
225
|
+
}
|
|
226
|
+
), /* @__PURE__ */ React.createElement(
|
|
227
|
+
Modal,
|
|
228
|
+
{
|
|
229
|
+
open: modalOpen,
|
|
230
|
+
onClick: (event) => event.stopPropagation(),
|
|
231
|
+
onClose: () => setModalOpen(false),
|
|
232
|
+
style: { overflow: "scroll" }
|
|
233
|
+
},
|
|
234
|
+
/* @__PURE__ */ React.createElement(FileContent, { filename: curFile, coverage: fileCoverage })
|
|
235
|
+
));
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export { FileExplorer, buildFileStructure, getObjectsAtPath, groupByPath };
|
|
239
|
+
//# sourceMappingURL=FileExplorer.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileExplorer.esm.js","sources":["../../../src/components/FileExplorer/FileExplorer.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 { humanizeEntityRef, useEntity } from '@backstage/plugin-catalog-react';\nimport Box from '@material-ui/core/Box';\nimport Modal from '@material-ui/core/Modal';\nimport { makeStyles } from '@material-ui/core/styles';\nimport FolderIcon from '@material-ui/icons/Folder';\nimport FileOutlinedIcon from '@material-ui/icons/InsertDriveFileOutlined';\nimport Alert from '@material-ui/lab/Alert';\nimport React, { Fragment, useEffect, useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { codeCoverageApiRef } from '../../api';\nimport { FileEntry } from '../../types';\nimport { FileContent } from './FileContent';\nimport {\n Progress,\n ResponseErrorPanel,\n Table,\n TableColumn,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\n\nconst useStyles = makeStyles(theme => ({\n container: {\n marginTop: theme.spacing(2),\n },\n icon: {\n marginRight: theme.spacing(1),\n },\n link: {\n color: theme.palette.primary.main,\n cursor: 'pointer',\n },\n}));\n\ntype FileStructureObject = Record<string, any>;\n\ntype CoverageTableRow = {\n filename?: string;\n files: CoverageTableRow[];\n coverage: number;\n missing: number;\n tracked: number;\n path: string;\n tableData?: { id: number };\n};\n\nexport const groupByPath = (files: CoverageTableRow[]) => {\n const acc: FileStructureObject = {};\n files.forEach(file => {\n const filename = file.filename;\n if (!file.filename) return;\n const pathArray = filename?.split('/').filter(el => el !== '');\n if (pathArray) {\n if (!acc.hasOwnProperty(pathArray[0])) {\n acc[pathArray[0]] = [];\n }\n acc[pathArray[0]].push(file);\n }\n });\n return acc;\n};\n\nconst removeVisitedPathGroup = (\n files: CoverageTableRow[],\n pathGroup: string,\n) => {\n return files.map(file => {\n return {\n ...file,\n filename: file.filename\n ? file.filename.substring(\n file.filename?.indexOf(pathGroup) + pathGroup.length + 1,\n )\n : file.filename,\n };\n });\n};\n\nexport const buildFileStructure = (row: CoverageTableRow) => {\n const dataGroupedByPath: FileStructureObject = groupByPath(row.files);\n row.files = Object.keys(dataGroupedByPath).map(pathGroup => {\n return buildFileStructure({\n path: pathGroup,\n files: dataGroupedByPath.hasOwnProperty('files')\n ? removeVisitedPathGroup(dataGroupedByPath.files, pathGroup)\n : removeVisitedPathGroup(dataGroupedByPath[pathGroup], pathGroup),\n coverage:\n dataGroupedByPath[pathGroup].reduce(\n (acc: number, cur: CoverageTableRow) => acc + cur.coverage,\n 0,\n ) / dataGroupedByPath[pathGroup].length,\n missing: dataGroupedByPath[pathGroup].reduce(\n (acc: number, cur: CoverageTableRow) => acc + cur.missing,\n 0,\n ),\n tracked: dataGroupedByPath[pathGroup].reduce(\n (acc: number, cur: CoverageTableRow) => acc + cur.tracked,\n 0,\n ),\n });\n });\n return row;\n};\n\nconst formatInitialData = (value: any) => {\n return buildFileStructure({\n path: '',\n coverage: value.aggregate.line.percentage,\n missing: value.aggregate.line.missed,\n tracked: value.aggregate.line.available,\n files: value.files.map((fc: FileEntry) => {\n return {\n path: '',\n filename: fc.filename,\n coverage: Math.floor(\n (Object.values(fc.lineHits).filter((hits: number) => hits > 0)\n .length /\n Object.values(fc.lineHits).length) *\n 100,\n ),\n missing: Object.values(fc.lineHits).filter(hits => !hits).length,\n tracked: Object.values(fc.lineHits).length,\n };\n }),\n });\n};\n\nexport const getObjectsAtPath = (\n curData: CoverageTableRow | undefined,\n path: string[],\n): CoverageTableRow[] | undefined => {\n let data = curData?.files;\n for (const fragment of path) {\n data = data?.find(d => d.path === fragment)?.files;\n }\n return data;\n};\n\nexport const FileExplorer = () => {\n const styles = useStyles();\n const { entity } = useEntity();\n const [curData, setCurData] = useState<CoverageTableRow | undefined>();\n const [tableData, setTableData] = useState<CoverageTableRow[] | undefined>();\n const [curPath, setCurPath] = useState('');\n const [modalOpen, setModalOpen] = useState(false);\n const [curFile, setCurFile] = useState('');\n const codeCoverageApi = useApi(codeCoverageApiRef);\n const { loading, error, value } = useAsync(\n async () =>\n await codeCoverageApi.getCoverageForEntity({\n kind: entity.kind,\n namespace: entity.metadata.namespace || 'default',\n name: entity.metadata.name,\n }),\n );\n\n useEffect(() => {\n if (!value) return;\n const data = formatInitialData(value);\n setCurData(data);\n if (data.files) setTableData(data.files);\n }, [value]);\n\n if (loading) {\n return <Progress />;\n } else if (error) {\n return <ResponseErrorPanel error={error} />;\n }\n if (!value) {\n return (\n <Alert severity=\"warning\">\n No code coverage found for {humanizeEntityRef(entity)}\n </Alert>\n );\n }\n\n const moveDownIntoPath = (path: string) => {\n const nextPathData = tableData!.find(\n (d: CoverageTableRow) => d.path === path,\n );\n if (nextPathData && nextPathData.files) {\n setTableData(nextPathData.files);\n }\n };\n\n const moveUpIntoPath = (idx: number) => {\n const path = curPath.split('/').slice(0, idx + 1);\n setCurFile('');\n setCurPath(path.join('/'));\n setTableData(getObjectsAtPath(curData, path.slice(1)));\n };\n\n const columns: TableColumn<CoverageTableRow>[] = [\n {\n title: 'Path',\n type: 'string',\n field: 'path',\n render: (row: CoverageTableRow) => (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n role=\"button\"\n tabIndex={row.tableData!.id}\n className={styles.link}\n onClick={() => {\n if (row.files?.length) {\n setCurPath(`${curPath}/${row.path}`);\n moveDownIntoPath(row.path);\n } else {\n setCurFile(`${curPath.slice(1)}/${row.path}`);\n setModalOpen(true);\n }\n }}\n >\n {row.files?.length > 0 && (\n <FolderIcon fontSize=\"small\" className={styles.icon} />\n )}\n {row.files?.length === 0 && (\n <FileOutlinedIcon fontSize=\"small\" className={styles.icon} />\n )}\n {row.path}\n </Box>\n ),\n },\n {\n title: 'Coverage',\n type: 'numeric',\n field: 'coverage',\n render: (row: CoverageTableRow) => `${row.coverage.toFixed(2)}%`,\n },\n {\n title: 'Missing lines',\n type: 'numeric',\n field: 'missing',\n },\n {\n title: 'Tracked lines',\n type: 'numeric',\n field: 'tracked',\n },\n ];\n\n const pathArray = curPath.split('/');\n const lastPathElementIndex = pathArray.length - 1;\n const fileCoverage = value.files.find((f: FileEntry) =>\n f.filename.endsWith(curFile),\n );\n\n if (!fileCoverage) {\n return null;\n }\n\n return (\n <Box className={styles.container}>\n <Table\n emptyContent={<>No files found</>}\n data={tableData || []}\n columns={columns}\n title={\n <>\n <Box>Explore Files</Box>\n <Box\n mt={1}\n style={{\n fontSize: '0.875rem',\n fontWeight: 'normal',\n display: 'flex',\n }}\n >\n {pathArray.map((pathElement, idx) => (\n <Fragment key={pathElement || 'root'}>\n <div\n role=\"button\"\n tabIndex={idx}\n className={\n idx !== lastPathElementIndex ? styles.link : undefined\n }\n onKeyDown={() => moveUpIntoPath(idx)}\n onClick={() => moveUpIntoPath(idx)}\n >\n {pathElement || 'root'}\n </div>\n {idx !== lastPathElementIndex && <div>{'\\u00A0/\\u00A0'}</div>}\n </Fragment>\n ))}\n </Box>\n </>\n }\n />\n <Modal\n open={modalOpen}\n onClick={event => event.stopPropagation()}\n onClose={() => setModalOpen(false)}\n style={{ overflow: 'scroll' }}\n >\n <FileContent filename={curFile} coverage={fileCoverage} />\n </Modal>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAoCA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,SAAW,EAAA;AAAA,IACT,SAAA,EAAW,KAAM,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
6
|
+
let fileformat = fileExtension;
|
|
7
|
+
if (fileExtension === "m") {
|
|
8
|
+
fileformat = "objectivec";
|
|
9
|
+
}
|
|
10
|
+
if (fileExtension === "tsx") {
|
|
11
|
+
fileformat = "typescript";
|
|
12
|
+
}
|
|
13
|
+
if (fileExtension === "jsx") {
|
|
14
|
+
fileformat = "javascript";
|
|
15
|
+
}
|
|
16
|
+
if (fileExtension === "kt") {
|
|
17
|
+
fileformat = "kotlin";
|
|
18
|
+
}
|
|
19
|
+
lines.forEach((line) => {
|
|
20
|
+
const result = hljs.highlight(line, {
|
|
21
|
+
language: fileformat,
|
|
22
|
+
ignoreIllegals: true
|
|
23
|
+
});
|
|
24
|
+
formattedLines.push(result.value);
|
|
25
|
+
});
|
|
26
|
+
return formattedLines;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { highlightLines };
|
|
30
|
+
//# sourceMappingURL=Highlighter.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Highlighter.esm.js","sources":["../../../src/components/FileExplorer/Highlighter.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 */\n\nimport 'highlight.js/styles/mono-blue.css';\nimport hljs from 'highlight.js';\n\n/*\n * Given a file extension, repo name, and array of code lines, return a Promise resolving\n * to an array of formatted lines with html/css formatting.\n *\n * @param fileExtension - The extension of the source file\n * @param lines - The source code lines\n *\n * @returns Promise of formatted lines\n *\n * @see http://highlightjs.readthedocs.io/en/latest/api.html#highlight-name-value-ignore-illegals-continuation\n */\nexport const highlightLines = (fileExtension: string, lines: Array<string>) => {\n const formattedLines: Array<string> = [];\n let fileformat = fileExtension;\n if (fileExtension === 'm') {\n fileformat = 'objectivec';\n }\n if (fileExtension === 'tsx') {\n fileformat = 'typescript';\n }\n if (fileExtension === 'jsx') {\n fileformat = 'javascript';\n }\n if (fileExtension === 'kt') {\n fileformat = 'kotlin';\n }\n\n lines.forEach(line => {\n const result = hljs.highlight(line, {\n language: fileformat,\n ignoreIllegals: true,\n });\n formattedLines.push(result.value);\n });\n return formattedLines;\n};\n"],"names":[],"mappings":";;;AA8Ba,MAAA,cAAA,GAAiB,CAAC,aAAA,EAAuB,KAAyB,KAAA;AAC7E,EAAA,MAAM,iBAAgC,EAAC,CAAA;AACvC,EAAA,IAAI,UAAa,GAAA,aAAA,CAAA;AACjB,EAAA,IAAI,kBAAkB,GAAK,EAAA;AACzB,IAAa,UAAA,GAAA,YAAA,CAAA;AAAA,GACf;AACA,EAAA,IAAI,kBAAkB,KAAO,EAAA;AAC3B,IAAa,UAAA,GAAA,YAAA,CAAA;AAAA,GACf;AACA,EAAA,IAAI,kBAAkB,KAAO,EAAA;AAC3B,IAAa,UAAA,GAAA,YAAA,CAAA;AAAA,GACf;AACA,EAAA,IAAI,kBAAkB,IAAM,EAAA;AAC1B,IAAa,UAAA,GAAA,QAAA,CAAA;AAAA,GACf;AAEA,EAAA,KAAA,CAAM,QAAQ,CAAQ,IAAA,KAAA;AACpB,IAAM,MAAA,MAAA,GAAS,IAAK,CAAA,SAAA,CAAU,IAAM,EAAA;AAAA,MAClC,QAAU,EAAA,UAAA;AAAA,MACV,cAAgB,EAAA,IAAA;AAAA,KACjB,CAAA,CAAA;AACD,IAAe,cAAA,CAAA,IAAA,CAAK,OAAO,KAAK,CAAA,CAAA;AAAA,GACjC,CAAA,CAAA;AACD,EAAO,OAAA,cAAA,CAAA;AACT;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useEntity, MissingAnnotationEmptyState } from '@backstage/plugin-catalog-react';
|
|
3
|
+
import { CodeCoveragePage } from './CodeCoveragePage/CodeCoveragePage.esm.js';
|
|
4
|
+
|
|
5
|
+
function isCodeCoverageAvailable(entity) {
|
|
6
|
+
return Boolean(entity.metadata.annotations?.["backstage.io/code-coverage"]);
|
|
7
|
+
}
|
|
8
|
+
const Router = () => {
|
|
9
|
+
const { entity } = useEntity();
|
|
10
|
+
if (!isCodeCoverageAvailable(entity)) {
|
|
11
|
+
return /* @__PURE__ */ React.createElement(MissingAnnotationEmptyState, { annotation: "backstage.io/code-coverage" });
|
|
12
|
+
}
|
|
13
|
+
return /* @__PURE__ */ React.createElement(CodeCoveragePage, null);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { Router, isCodeCoverageAvailable };
|
|
17
|
+
//# sourceMappingURL=Router.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Router.esm.js","sources":["../../src/components/Router.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 React from 'react';\nimport { Entity } from '@backstage/catalog-model';\nimport {\n useEntity,\n MissingAnnotationEmptyState,\n} from '@backstage/plugin-catalog-react';\nimport { CodeCoveragePage } from './CodeCoveragePage';\n\n/**\n * Returns true if the given entity has code coverage enabled.\n *\n * @public\n */\nexport function isCodeCoverageAvailable(entity: Entity) {\n return Boolean(entity.metadata.annotations?.['backstage.io/code-coverage']);\n}\n\n/**\n * @public\n */\nexport const Router = (): JSX.Element => {\n const { entity } = useEntity();\n\n if (!isCodeCoverageAvailable(entity)) {\n return (\n <MissingAnnotationEmptyState annotation=\"backstage.io/code-coverage\" />\n );\n }\n\n return <CodeCoveragePage />;\n};\n"],"names":[],"mappings":";;;;AA6BO,SAAS,wBAAwB,MAAgB,EAAA;AACtD,EAAA,OAAO,OAAQ,CAAA,MAAA,CAAO,QAAS,CAAA,WAAA,GAAc,4BAA4B,CAAC,CAAA,CAAA;AAC5E,CAAA;AAKO,MAAM,SAAS,MAAmB;AACvC,EAAM,MAAA,EAAE,MAAO,EAAA,GAAI,SAAU,EAAA,CAAA;AAE7B,EAAI,IAAA,CAAC,uBAAwB,CAAA,MAAM,CAAG,EAAA;AACpC,IACE,uBAAA,KAAA,CAAA,aAAA,CAAC,2BAA4B,EAAA,EAAA,UAAA,EAAW,4BAA6B,EAAA,CAAA,CAAA;AAAA,GAEzE;AAEA,EAAA,2CAAQ,gBAAiB,EAAA,IAAA,CAAA,CAAA;AAC3B;;;;"}
|