From f985cb6dcb57467eaa855bfd31382f3d11d5b6f3 Mon Sep 17 00:00:00 2001 From: Ben Simpson Date: Wed, 11 Oct 2023 13:08:32 +0100 Subject: [PATCH 1/2] [refactor] Update report package to use TS --- .../assets/packages/report/.eslintrc.json | 3 +- .../assets/packages/report/.prettierignore | 6 +++ .../assets/packages/report/dist/index.html | 50 ++++++++++--------- dashboard/assets/packages/report/index.html | 32 ++++++------ dashboard/assets/packages/report/package.json | 18 +++++-- .../report/src/{ => components/App}/App.css | 0 .../src/{App.jsx => components/App/App.tsx} | 9 +++- .../report/src/components/App/index.ts | 1 + .../src/{ => components/Chart}/Chart.css | 0 .../{Chart.jsx => components/Chart/Chart.tsx} | 36 ++++++++----- .../report/src/components/Chart/index.ts | 1 + .../src/{Panel.jsx => components/Panel.tsx} | 13 +++-- .../{Section.jsx => components/Section.tsx} | 17 ++++--- .../src/{ => components/Summary}/Summary.css | 0 .../Summary/Summary.tsx} | 9 +++- .../report/src/components/Summary/index.ts | 1 + .../src/{Tab.jsx => components/Tab.tsx} | 10 +++- .../report/src/{main.jsx => main.tsx} | 10 ++-- .../report/src/{ => theme}/styles.scss | 49 +++++++++--------- .../packages/report/src/types/config.ts | 18 +++++++ .../src/typings/xk6-dashboard-model.d.ts | 15 ++++++ .../report/src/{colors.js => utils/colors.ts} | 4 +- .../report/src/{digest.js => utils/digest.ts} | 24 ++++++--- .../assets/packages/report/tsconfig.json | 26 ++++++++++ .../packages/report/tsconfig.json.license | 3 ++ .../assets/packages/report/tsconfig.node.json | 10 ++++ .../report/tsconfig.node.json.license | 3 ++ .../report/{vite.config.js => vite.config.ts} | 4 +- 28 files changed, 260 insertions(+), 112 deletions(-) create mode 100644 dashboard/assets/packages/report/.prettierignore rename dashboard/assets/packages/report/src/{ => components/App}/App.css (100%) rename dashboard/assets/packages/report/src/{App.jsx => components/App/App.tsx} (79%) create mode 100644 dashboard/assets/packages/report/src/components/App/index.ts rename dashboard/assets/packages/report/src/{ => components/Chart}/Chart.css (100%) rename dashboard/assets/packages/report/src/{Chart.jsx => components/Chart/Chart.tsx} (58%) create mode 100644 dashboard/assets/packages/report/src/components/Chart/index.ts rename dashboard/assets/packages/report/src/{Panel.jsx => components/Panel.tsx} (51%) rename dashboard/assets/packages/report/src/{Section.jsx => components/Section.tsx} (69%) rename dashboard/assets/packages/report/src/{ => components/Summary}/Summary.css (100%) rename dashboard/assets/packages/report/src/{Summary.jsx => components/Summary/Summary.tsx} (81%) create mode 100644 dashboard/assets/packages/report/src/components/Summary/index.ts rename dashboard/assets/packages/report/src/{Tab.jsx => components/Tab.tsx} (67%) rename dashboard/assets/packages/report/src/{main.jsx => main.tsx} (55%) rename dashboard/assets/packages/report/src/{ => theme}/styles.scss (64%) create mode 100644 dashboard/assets/packages/report/src/types/config.ts create mode 100644 dashboard/assets/packages/report/src/typings/xk6-dashboard-model.d.ts rename dashboard/assets/packages/report/src/{colors.js => utils/colors.ts} (99%) rename dashboard/assets/packages/report/src/{digest.js => utils/digest.ts} (59%) create mode 100644 dashboard/assets/packages/report/tsconfig.json create mode 100644 dashboard/assets/packages/report/tsconfig.json.license create mode 100644 dashboard/assets/packages/report/tsconfig.node.json create mode 100644 dashboard/assets/packages/report/tsconfig.node.json.license rename dashboard/assets/packages/report/{vite.config.js => vite.config.ts} (75%) diff --git a/dashboard/assets/packages/report/.eslintrc.json b/dashboard/assets/packages/report/.eslintrc.json index 565f2a2..8b7d58c 100644 --- a/dashboard/assets/packages/report/.eslintrc.json +++ b/dashboard/assets/packages/report/.eslintrc.json @@ -3,7 +3,8 @@ "browser": true, "es2021": true }, - "extends": ["eslint:recommended", "plugin:react/recommended", "prettier"], + "extends": ["eslint:recommended", "plugin:react/recommended", "plugin:@typescript-eslint/recommended", "prettier"], + "ignorePatterns": ["dist", ".eslintrc.json"], "plugins": ["react", "prettier"], "parserOptions": { "ecmaVersion": "latest", diff --git a/dashboard/assets/packages/report/.prettierignore b/dashboard/assets/packages/report/.prettierignore new file mode 100644 index 0000000..624304f --- /dev/null +++ b/dashboard/assets/packages/report/.prettierignore @@ -0,0 +1,6 @@ +# SPDX-FileCopyrightText: 2023 Raintank, Inc. dba Grafana Labs +# +# SPDX-License-Identifier: AGPL-3.0-only + +dist/ +*.md \ No newline at end of file diff --git a/dashboard/assets/packages/report/dist/index.html b/dashboard/assets/packages/report/dist/index.html index 40b731d..551a728 100644 --- a/dashboard/assets/packages/report/dist/index.html +++ b/dashboard/assets/packages/report/dist/index.html @@ -4,25 +4,26 @@ SPDX-License-Identifier: AGPL-3.0-only --> - + - - - - - - k6 report - - - - - -
- - - + + +
+ + + diff --git a/dashboard/assets/packages/report/index.html b/dashboard/assets/packages/report/index.html index 7479453..73d39ce 100644 --- a/dashboard/assets/packages/report/index.html +++ b/dashboard/assets/packages/report/index.html @@ -4,21 +4,23 @@ SPDX-License-Identifier: AGPL-3.0-only --> - + + + + + + k6 report + - - - - - k6 report - - - -
- - - - + +
+ + + diff --git a/dashboard/assets/packages/report/package.json b/dashboard/assets/packages/report/package.json index b6c7ba1..b822661 100644 --- a/dashboard/assets/packages/report/package.json +++ b/dashboard/assets/packages/report/package.json @@ -6,13 +6,17 @@ "scripts": { "dev": "vite", "build": "vite build --emptyOutDir", - "preview": "vite preview" + "preview": "vite preview", + "lint:eslint": "eslint \"./src/**/*.{js,jsx,ts,tsx}\"", + "lint:format": "prettier --ignore-unknown --check \"./**/*\"", + "lint:types": "tsc --noEmit", + "lint": "yarn lint:eslint && yarn lint:types && yarn lint:format" }, "dependencies": { "@xk6-dashboard/config": "0.0.1", "@xk6-dashboard/model": "0.0.1", "@xk6-dashboard/view": "0.0.1", - "bootstrap": "^5.3.1", + "bootstrap": "^5.3.2", "preact": "^10.16.0", "react": "npm:@preact/compat", "react-dom": "npm:@preact/compat", @@ -22,9 +26,15 @@ }, "devDependencies": { "@preact/preset-vite": "^2.5.0", + "@typescript-eslint/eslint-plugin": "^6.7.5", + "@typescript-eslint/parser": "^6.7.5", + "eslint": "^8.51.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-prettier": "^5.0.1", "sass": "^1.65.1", - "vite": "^4.4.5", + "vite": "^4.4.11", "vite-plugin-handlebars": "^1.6.0", - "vite-plugin-singlefile": "^0.13.5" + "vite-plugin-singlefile": "^0.13.5", + "vite-tsconfig-paths": "^4.2.1" } } diff --git a/dashboard/assets/packages/report/src/App.css b/dashboard/assets/packages/report/src/components/App/App.css similarity index 100% rename from dashboard/assets/packages/report/src/App.css rename to dashboard/assets/packages/report/src/components/App/App.css diff --git a/dashboard/assets/packages/report/src/App.jsx b/dashboard/assets/packages/report/src/components/App/App.tsx similarity index 79% rename from dashboard/assets/packages/report/src/App.jsx rename to dashboard/assets/packages/report/src/components/App/App.tsx index 9ae97ae..79db330 100644 --- a/dashboard/assets/packages/report/src/App.jsx +++ b/dashboard/assets/packages/report/src/components/App/App.tsx @@ -5,11 +5,16 @@ // SPDX-License-Identifier: MIT import React from "react" +import { Digest } from "@xk6-dashboard/model" + +import Tab from "components/Tab" import "./App.css" -import Tab from "./Tab" +interface AppProps { + digest: Digest +} -export default function App({ digest }) { +export default function App({ digest }: AppProps) { return (

k6 report

diff --git a/dashboard/assets/packages/report/src/components/App/index.ts b/dashboard/assets/packages/report/src/components/App/index.ts new file mode 100644 index 0000000..d931b54 --- /dev/null +++ b/dashboard/assets/packages/report/src/components/App/index.ts @@ -0,0 +1 @@ +export { default } from "./App" diff --git a/dashboard/assets/packages/report/src/Chart.css b/dashboard/assets/packages/report/src/components/Chart/Chart.css similarity index 100% rename from dashboard/assets/packages/report/src/Chart.css rename to dashboard/assets/packages/report/src/components/Chart/Chart.css diff --git a/dashboard/assets/packages/report/src/Chart.jsx b/dashboard/assets/packages/report/src/components/Chart/Chart.tsx similarity index 58% rename from dashboard/assets/packages/report/src/Chart.jsx rename to dashboard/assets/packages/report/src/components/Chart/Chart.tsx index 968948f..ecb16bf 100644 --- a/dashboard/assets/packages/report/src/Chart.jsx +++ b/dashboard/assets/packages/report/src/components/Chart/Chart.tsx @@ -2,29 +2,39 @@ // // SPDX-License-Identifier: AGPL-3.0-only -import React from "react" +import React, { Ref } from "react" import { useRef, useState, useLayoutEffect } from "preact/hooks" import "uplot/dist/uPlot.min.css" import UplotReact from "uplot-react" -import uPlot from "uplot" +import uPlot, { AlignedData, Options, Series } from "uplot" -import { SeriesPlot, tooltipPlugin, dateFormats, format } from "@xk6-dashboard/view" +import { Digest } from "@xk6-dashboard/model" +import { Panel, SeriesPlot, tooltipPlugin, dateFormats, format } from "@xk6-dashboard/view" +import colors from "utils/colors" import "./Chart.css" -import colors from "./colors" - const sync = uPlot.sync("chart") -export default function Chart({ panel, digest }) { +interface ChartProps { + panel: Panel + digest: Digest +} + +export default function Chart({ panel, digest }: ChartProps) { const plot = new SeriesPlot(digest, panel, colors) - const ref = useRef(null) + const ref = useRef(null) const [width, setWidth] = useState(0) useLayoutEffect(() => { - let updateWidth = () => setWidth(ref.current.offsetWidth) + const updateWidth = () => { + if (ref.current) { + setWidth(ref.current.offsetWidth) + } + } + updateWidth() window.addEventListener("resize", updateWidth) @@ -35,13 +45,13 @@ export default function Chart({ panel, digest }) { return } - let options = { + const options: Options = { width: width, height: 250, title: panel.title, cursor: { sync: { key: sync.key } }, legend: { live: false }, - series: plot.series, + series: plot.series as Series[], axes: [{}], plugins: [tooltipPlugin("#fafafa")] } @@ -51,7 +61,7 @@ export default function Chart({ panel, digest }) { stroke: "#808080", grid: { stroke: "#f0f0f0" }, ticks: { stroke: "#f0f0f0" }, - values: (self, ticks) => ticks.map((val) => format(unit, val)), + values: (_, ticks) => ticks.map((val) => format(unit, val)), size: 70, scale: unit } @@ -65,8 +75,8 @@ export default function Chart({ panel, digest }) { } return ( -
- +
} className="chart panel"> +
) } diff --git a/dashboard/assets/packages/report/src/components/Chart/index.ts b/dashboard/assets/packages/report/src/components/Chart/index.ts new file mode 100644 index 0000000..8024f33 --- /dev/null +++ b/dashboard/assets/packages/report/src/components/Chart/index.ts @@ -0,0 +1 @@ +export { default } from "./Chart" diff --git a/dashboard/assets/packages/report/src/Panel.jsx b/dashboard/assets/packages/report/src/components/Panel.tsx similarity index 51% rename from dashboard/assets/packages/report/src/Panel.jsx rename to dashboard/assets/packages/report/src/components/Panel.tsx index 8652a86..56f14a2 100644 --- a/dashboard/assets/packages/report/src/Panel.jsx +++ b/dashboard/assets/packages/report/src/components/Panel.tsx @@ -3,13 +3,18 @@ // SPDX-License-Identifier: AGPL-3.0-only import React from "react" +import { Digest } from "@xk6-dashboard/model" +import { Panel as PanelClass, PanelKind } from "@xk6-dashboard/view" -import { PanelKind } from "@xk6-dashboard/view" +import Chart from "components/Chart" +import Summary from "components/Summary" -import Chart from "./Chart" -import Summary from "./Summary" +interface PanelProps { + panel: PanelClass + digest: Digest +} -export default function Panel({ panel, digest }) { +export default function Panel({ panel, digest }: PanelProps) { if (panel.kind == PanelKind.chart) { return } diff --git a/dashboard/assets/packages/report/src/Section.jsx b/dashboard/assets/packages/report/src/components/Section.tsx similarity index 69% rename from dashboard/assets/packages/report/src/Section.jsx rename to dashboard/assets/packages/report/src/components/Section.tsx index 720fbd4..6a446a6 100644 --- a/dashboard/assets/packages/report/src/Section.jsx +++ b/dashboard/assets/packages/report/src/components/Section.tsx @@ -3,19 +3,24 @@ // SPDX-License-Identifier: AGPL-3.0-only import React from "react" - -import { SummaryTable, isEmptySection } from "@xk6-dashboard/view" +import { Digest } from "@xk6-dashboard/model" +import { Panel as PanelClass, Section as SectionClass, SummaryTable, isEmptySection } from "@xk6-dashboard/view" import Panel from "./Panel" -export default function Section({ section, digest }) { +interface SectionProps { + section: SectionClass + digest: Digest +} + +export default function Section({ section, digest }: SectionProps) { const empty = isEmptySection(section, digest) if (empty) { return <> } - const foo = (panel) => { + const createClassName = (panel: PanelClass) => { if (panel.kind == "chart") { return "col-lg-6 rcol-md-12" } @@ -40,8 +45,8 @@ export default function Section({ section, digest }) {

{section.summary}

{section.panels.map((panel) => ( -
- +
+
))}
diff --git a/dashboard/assets/packages/report/src/Summary.css b/dashboard/assets/packages/report/src/components/Summary/Summary.css similarity index 100% rename from dashboard/assets/packages/report/src/Summary.css rename to dashboard/assets/packages/report/src/components/Summary/Summary.css diff --git a/dashboard/assets/packages/report/src/Summary.jsx b/dashboard/assets/packages/report/src/components/Summary/Summary.tsx similarity index 81% rename from dashboard/assets/packages/report/src/Summary.jsx rename to dashboard/assets/packages/report/src/components/Summary/Summary.tsx index ccb6f0c..05336e6 100644 --- a/dashboard/assets/packages/report/src/Summary.jsx +++ b/dashboard/assets/packages/report/src/components/Summary/Summary.tsx @@ -3,12 +3,17 @@ // SPDX-License-Identifier: AGPL-3.0-only import React from "react" +import { Digest } from "@xk6-dashboard/model" +import { Panel, SummaryTable } from "@xk6-dashboard/view" import "./Summary.css" -import { SummaryTable } from "@xk6-dashboard/view" +interface SummaryProps { + panel: Panel + digest: Digest +} -export default function Summary({ panel, digest }) { +export default function Summary({ panel, digest }: SummaryProps) { const table = new SummaryTable(panel, digest) if (table.empty) { diff --git a/dashboard/assets/packages/report/src/components/Summary/index.ts b/dashboard/assets/packages/report/src/components/Summary/index.ts new file mode 100644 index 0000000..e402864 --- /dev/null +++ b/dashboard/assets/packages/report/src/components/Summary/index.ts @@ -0,0 +1 @@ +export { default } from "./Summary" diff --git a/dashboard/assets/packages/report/src/Tab.jsx b/dashboard/assets/packages/report/src/components/Tab.tsx similarity index 67% rename from dashboard/assets/packages/report/src/Tab.jsx rename to dashboard/assets/packages/report/src/components/Tab.tsx index 0ca4ae0..02a4f1e 100644 --- a/dashboard/assets/packages/report/src/Tab.jsx +++ b/dashboard/assets/packages/report/src/components/Tab.tsx @@ -3,9 +3,17 @@ // SPDX-License-Identifier: AGPL-3.0-only import React from "react" +import { Digest } from "@xk6-dashboard/model" + +import { Tab as TabType } from "types/config" import Section from "./Section" -export default function Tab({ tab, digest }) { +interface TabProps { + tab: TabType + digest: Digest +} + +export default function Tab({ tab, digest }: TabProps) { return (

{tab.title}

diff --git a/dashboard/assets/packages/report/src/main.jsx b/dashboard/assets/packages/report/src/main.tsx similarity index 55% rename from dashboard/assets/packages/report/src/main.jsx rename to dashboard/assets/packages/report/src/main.tsx index 9b813ce..89640b8 100644 --- a/dashboard/assets/packages/report/src/main.jsx +++ b/dashboard/assets/packages/report/src/main.tsx @@ -6,11 +6,11 @@ import React from "react" import { render } from "preact" -import digest from "./digest" - import "uplot/dist/uPlot.min.css" -import "./styles.scss" -import App from "./App.jsx" +import digest from "utils/digest" +import App from "components/App" +import "theme/styles.scss" -digest().then((d) => render(, document.getElementById("root"))) +const rootElement = document.getElementById("root") as HTMLDivElement +digest().then((d) => render(, rootElement)) diff --git a/dashboard/assets/packages/report/src/styles.scss b/dashboard/assets/packages/report/src/theme/styles.scss similarity index 64% rename from dashboard/assets/packages/report/src/styles.scss rename to dashboard/assets/packages/report/src/theme/styles.scss index cd5742e..aecdc1d 100644 --- a/dashboard/assets/packages/report/src/styles.scss +++ b/dashboard/assets/packages/report/src/theme/styles.scss @@ -24,45 +24,46 @@ // local @media print { - .chapter { - break-after: page; - } + .chapter { + break-after: page; + } - .usage { - display: none; - } + .usage { + display: none; + } - .container { - margin-left:unset; - } + .container { + margin-left: unset; + } } @media screen { - .container { - max-width: unset !important; - } + .container { + max-width: unset !important; + } - body { - margin: 1rem; - } + body { + margin: 1rem; + } } -h1, h2, h3 { - font-weight: 400; +h1, +h2, +h3 { + font-weight: 400; } h2 { - border-bottom: 1px solid #e0e0e0; + border-bottom: 1px solid #e0e0e0; } @media print { - h1 { - padding-left: unset !important; - padding-right: unset !important; - } + h1 { + padding-left: unset !important; + padding-right: unset !important; + } } h1 { - text-align: center; + text-align: center; } - diff --git a/dashboard/assets/packages/report/src/types/config.ts b/dashboard/assets/packages/report/src/types/config.ts new file mode 100644 index 0000000..7fdf551 --- /dev/null +++ b/dashboard/assets/packages/report/src/types/config.ts @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: 2023 Raintank, Inc. dba Grafana Labs +// +// SPDX-License-Identifier: AGPL-3.0-only + +import { Section } from "@xk6-dashboard/view" + +export interface Tab { + title?: string + id?: string + summary?: string + report?: boolean + sections: Section[] +} + +export interface UIConfig { + title: string + tabs: Tab[] +} diff --git a/dashboard/assets/packages/report/src/typings/xk6-dashboard-model.d.ts b/dashboard/assets/packages/report/src/typings/xk6-dashboard-model.d.ts new file mode 100644 index 0000000..a1817ec --- /dev/null +++ b/dashboard/assets/packages/report/src/typings/xk6-dashboard-model.d.ts @@ -0,0 +1,15 @@ +// SPDX-FileCopyrightText: 2023 Raintank, Inc. dba Grafana Labs +// +// SPDX-License-Identifier: AGPL-3.0-only + +import "@xk6-dashboard/model" + +import { UIConfig } from "types/config" + +declare module "@xk6-dashboard/model" { + interface Config extends UIConfig {} + + interface Digest { + config?: UIConfig + } +} diff --git a/dashboard/assets/packages/report/src/colors.js b/dashboard/assets/packages/report/src/utils/colors.ts similarity index 99% rename from dashboard/assets/packages/report/src/colors.js rename to dashboard/assets/packages/report/src/utils/colors.ts index fd1bd9e..2c1b543 100644 --- a/dashboard/assets/packages/report/src/colors.js +++ b/dashboard/assets/packages/report/src/utils/colors.ts @@ -24,7 +24,7 @@ const materialColors = { brown: { 50: "#efebe9", 100: "#d7ccc8", 200: "#bcaaa4", 300: "#a1887f", 400: "#8d6e63", 500: "#795548", 600: "#6d4c41", 700: "#5d4037", 800: "#4e342e", 900: "#3e2723", A100: "#d7ccc8", A200: "#bcaaa4", A400: "#8d6e63", A700: "#5d4037", stroke: "dark" }, grey: { 50: "#fafafa", 100: "#f5f5f5", 200: "#eeeeee", 300: "#e0e0e0", 400: "#bdbdbd", 500: "#9e9e9e", 600: "#757575", 700: "#616161", 800: "#424242", 900: "#212121", A100: "#f5f5f5", A200: "#eeeeee", A400: "#bdbdbd", A700: "#616161", stroke: "dark" }, blueGrey: { 50: "#eceff1", 100: "#cfd8dc", 200: "#b0bec5", 300: "#90a4ae", 400: "#78909c", 500: "#607d8b", 600: "#546e7a", 700: "#455a64", 800: "#37474f", 900: "#263238", A100: "#cfd8dc", A200: "#b0bec5", A400: "#78909c", A700: "#455a64", stroke: "dark" } -} +} as const const order = [ "grey", @@ -46,7 +46,7 @@ const order = [ "yellow", "deepOrange", "blueGrey" -] +] as const const colors = order.map((name) => { return { diff --git a/dashboard/assets/packages/report/src/digest.js b/dashboard/assets/packages/report/src/utils/digest.ts similarity index 59% rename from dashboard/assets/packages/report/src/digest.js rename to dashboard/assets/packages/report/src/utils/digest.ts index 075896c..4dcd78d 100644 --- a/dashboard/assets/packages/report/src/digest.js +++ b/dashboard/assets/packages/report/src/utils/digest.ts @@ -7,14 +7,22 @@ import { Digest } from "@xk6-dashboard/model" export default async function () { - var blob = new Blob([Uint8Array.from(atob(document.getElementById("data").innerText), (m) => m.codePointAt(0))]) - var resp = await new Response(blob.stream().pipeThrough(new DecompressionStream("gzip")).pipeThrough(new TextDecoderStream())) + const dataElement = document.getElementById("data")! + const codePointAt = (m: string) => m.codePointAt(0)! const digest = new Digest() + const blob = new Blob([Uint8Array.from(atob(dataElement.innerText), codePointAt)]) + const resp = await new Response( + blob.stream().pipeThrough(new DecompressionStream("gzip")).pipeThrough(new TextDecoderStream()) + ) - for await (let line of makeTextFileLineIterator(resp.body.getReader())) { + if (!resp.body) { + return digest + } + + for await (const line of makeTextFileLineIterator(resp.body.getReader())) { if (!line || line.length == 0) continue - let envelope = JSON.parse(line) + const envelope = JSON.parse(line) digest.onEvent(envelope.event, envelope.data) } @@ -22,20 +30,20 @@ export default async function () { } // based on https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader/read#example_2_-_handling_text_line_by_line -async function* makeTextFileLineIterator(reader) { +async function* makeTextFileLineIterator(reader: ReadableStreamDefaultReader) { let { value, done } = await reader.read() - let re = /\r\n|\n|\r/gm + const re = /\r\n|\n|\r/gm let startIndex = 0 while (true) { - let result = re.exec(value) + const result = re.exec(value) if (!result) { if (done) { break } - let remainder = value.substr(startIndex) + const remainder = value.substr(startIndex) ;({ value, done } = await reader.read()) value = remainder + (value || "") startIndex = re.lastIndex = 0 diff --git a/dashboard/assets/packages/report/tsconfig.json b/dashboard/assets/packages/report/tsconfig.json new file mode 100644 index 0000000..622dbf3 --- /dev/null +++ b/dashboard/assets/packages/report/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + "baseUrl": "src", + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/dashboard/assets/packages/report/tsconfig.json.license b/dashboard/assets/packages/report/tsconfig.json.license new file mode 100644 index 0000000..f5b51f2 --- /dev/null +++ b/dashboard/assets/packages/report/tsconfig.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2023 Raintank, Inc. dba Grafana Labs + +SPDX-License-Identifier: AGPL-3.0-only diff --git a/dashboard/assets/packages/report/tsconfig.node.json b/dashboard/assets/packages/report/tsconfig.node.json new file mode 100644 index 0000000..42872c5 --- /dev/null +++ b/dashboard/assets/packages/report/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/dashboard/assets/packages/report/tsconfig.node.json.license b/dashboard/assets/packages/report/tsconfig.node.json.license new file mode 100644 index 0000000..f5b51f2 --- /dev/null +++ b/dashboard/assets/packages/report/tsconfig.node.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2023 Raintank, Inc. dba Grafana Labs + +SPDX-License-Identifier: AGPL-3.0-only diff --git a/dashboard/assets/packages/report/vite.config.js b/dashboard/assets/packages/report/vite.config.ts similarity index 75% rename from dashboard/assets/packages/report/vite.config.js rename to dashboard/assets/packages/report/vite.config.ts index 6ae92d0..3f648ae 100644 --- a/dashboard/assets/packages/report/vite.config.js +++ b/dashboard/assets/packages/report/vite.config.ts @@ -8,8 +8,10 @@ import { defineConfig } from "vite" import preact from "@preact/preset-vite" import { viteSingleFile } from "vite-plugin-singlefile" import handlebars from "vite-plugin-handlebars" +import tsconfigPaths from "vite-tsconfig-paths" + import testcontext from "./.testcontext" export default defineConfig({ - plugins: [preact(), viteSingleFile(), handlebars({ context: testcontext })] + plugins: [preact(), viteSingleFile(), tsconfigPaths(), handlebars({ context: testcontext })] }) From 5717ad5aa2364a41766e30b727ca2cd37ffcd142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20SZKIBA?= Date: Tue, 17 Oct 2023 15:42:02 +0200 Subject: [PATCH 2/2] chore: added license headers --- .../report/src/components/App/index.ts | 4 + .../report/src/components/Chart/index.ts | 4 + .../report/src/components/Summary/index.ts | 4 + dashboard/assets/yarn.lock | 75 +++++++++++++++---- 4 files changed, 72 insertions(+), 15 deletions(-) diff --git a/dashboard/assets/packages/report/src/components/App/index.ts b/dashboard/assets/packages/report/src/components/App/index.ts index d931b54..1beb10e 100644 --- a/dashboard/assets/packages/report/src/components/App/index.ts +++ b/dashboard/assets/packages/report/src/components/App/index.ts @@ -1 +1,5 @@ +// SPDX-FileCopyrightText: 2023 Raintank, Inc. dba Grafana Labs +// +// SPDX-License-Identifier: AGPL-3.0-only + export { default } from "./App" diff --git a/dashboard/assets/packages/report/src/components/Chart/index.ts b/dashboard/assets/packages/report/src/components/Chart/index.ts index 8024f33..e9af8c9 100644 --- a/dashboard/assets/packages/report/src/components/Chart/index.ts +++ b/dashboard/assets/packages/report/src/components/Chart/index.ts @@ -1 +1,5 @@ +// SPDX-FileCopyrightText: 2023 Raintank, Inc. dba Grafana Labs +// +// SPDX-License-Identifier: AGPL-3.0-only + export { default } from "./Chart" diff --git a/dashboard/assets/packages/report/src/components/Summary/index.ts b/dashboard/assets/packages/report/src/components/Summary/index.ts index e402864..02b6061 100644 --- a/dashboard/assets/packages/report/src/components/Summary/index.ts +++ b/dashboard/assets/packages/report/src/components/Summary/index.ts @@ -1 +1,5 @@ +// SPDX-FileCopyrightText: 2023 Raintank, Inc. dba Grafana Labs +// +// SPDX-License-Identifier: AGPL-3.0-only + export { default } from "./Summary" diff --git a/dashboard/assets/yarn.lock b/dashboard/assets/yarn.lock index 5910869..c3e6bdc 100644 --- a/dashboard/assets/yarn.lock +++ b/dashboard/assets/yarn.lock @@ -502,6 +502,11 @@ resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.49.0.tgz#86f79756004a97fa4df866835093f1df3d03c333" integrity sha512-1S8uAY/MTJqVx0SC4epBq+N2yhuwtNwLbJYNZyhL2pO1ZVKn5HFXav5T41Ryzy9K9V7ZId2JB2oy/W4aCd9/2w== +"@eslint/js@8.51.0": + version "8.51.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.51.0.tgz#6d419c240cfb2b66da37df230f7e7eef801c32fa" + integrity sha512-HxjQ8Qn+4SI3/AFv6sOrDB+g6PpUTDwSJiQqOrnneEk8L71161srI9gjzzZvYVbzHiVg/BvcH95+cK/zfIt4pg== + "@floating-ui/core@^1.4.1": version "1.4.1" resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.4.1.tgz#0d633f4b76052668afb932492ac452f7ebe97f17" @@ -1948,10 +1953,10 @@ bl@^4.0.3, bl@^4.1.0: inherits "^2.0.4" readable-stream "^3.4.0" -bootstrap@^5.3.1: - version "5.3.1" - resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.3.1.tgz#8ca07040ad15d7f75891d1504cf14c5dedfb1cfe" - integrity sha512-jzwza3Yagduci2x0rr9MeFSORjcHpt0lRZukZPZQJT1Dth5qzV7XcgGqYzi39KGAVYR8QEDVoO0ubFKOxzMG+g== +bootstrap@^5.3.2: + version "5.3.2" + resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.3.2.tgz#97226583f27aae93b2b28ab23f4c114757ff16ae" + integrity sha512-D32nmNWiQHo94BKHLmOrdjlL05q1c8oxbtBphQFb9Z5to6eGRDCm0QgeaZ4zFBHzfg2++rqa2JkqCcxDy0sH0g== bplist-parser@^0.2.0: version "0.2.0" @@ -2990,6 +2995,14 @@ eslint-plugin-prettier@^5.0.0: prettier-linter-helpers "^1.0.0" synckit "^0.8.5" +eslint-plugin-prettier@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.0.1.tgz#a3b399f04378f79f066379f544e42d6b73f11515" + integrity sha512-m3u5RnR56asrwV/lDC4GHorlW75DsFfmUcjfCYylTUs85dBRnB7VM6xG8eCMJdeDRnppzmxZVf1GEPJvl1JmNg== + dependencies: + prettier-linter-helpers "^1.0.0" + synckit "^0.8.5" + eslint-plugin-promise@^6.0.0: version "6.1.1" resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz#269a3e2772f62875661220631bd4dafcb4083816" @@ -3126,6 +3139,49 @@ eslint@^8.49.0: strip-ansi "^6.0.1" text-table "^0.2.0" +eslint@^8.51.0: + version "8.51.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.51.0.tgz#4a82dae60d209ac89a5cff1604fea978ba4950f3" + integrity sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA== + dependencies: + "@eslint-community/eslint-utils" "^4.2.0" + "@eslint-community/regexpp" "^4.6.1" + "@eslint/eslintrc" "^2.1.2" + "@eslint/js" "8.51.0" + "@humanwhocodes/config-array" "^0.11.11" + "@humanwhocodes/module-importer" "^1.0.1" + "@nodelib/fs.walk" "^1.2.8" + ajv "^6.12.4" + chalk "^4.0.0" + cross-spawn "^7.0.2" + debug "^4.3.2" + doctrine "^3.0.0" + escape-string-regexp "^4.0.0" + eslint-scope "^7.2.2" + eslint-visitor-keys "^3.4.3" + espree "^9.6.1" + esquery "^1.4.2" + esutils "^2.0.2" + fast-deep-equal "^3.1.3" + file-entry-cache "^6.0.1" + find-up "^5.0.0" + glob-parent "^6.0.2" + globals "^13.19.0" + graphemer "^1.4.0" + ignore "^5.2.0" + imurmurhash "^0.1.4" + is-glob "^4.0.0" + is-path-inside "^3.0.3" + js-yaml "^4.1.0" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.4.1" + lodash.merge "^4.6.2" + minimatch "^3.1.2" + natural-compare "^1.4.0" + optionator "^0.9.3" + strip-ansi "^6.0.1" + text-table "^0.2.0" + espree@^9.6.0, espree@^9.6.1: version "9.6.1" resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" @@ -6940,17 +6996,6 @@ vite@^4.4.11: optionalDependencies: fsevents "~2.3.2" -vite@^4.4.5: - version "4.4.9" - resolved "https://registry.yarnpkg.com/vite/-/vite-4.4.9.tgz#1402423f1a2f8d66fd8d15e351127c7236d29d3d" - integrity sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA== - dependencies: - esbuild "^0.18.10" - postcss "^8.4.27" - rollup "^3.27.1" - optionalDependencies: - fsevents "~2.3.2" - wcwidth@^1.0.0, wcwidth@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8"