From afa87af01c79a9baa539f2992d32154d2a4739bd Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Sat, 14 Feb 2026 14:46:37 -0800 Subject: task: delete vanilla js prototype\n\n- Removed vanilla/ directory and web/dist/vanilla directory\n- Updated Makefile, Dockerfile, and CI workflow to remove vanilla references\n- Cleaned up web/web.go to remove vanilla embed and routes\n- Verified build and tests pass\n\nCloses NK-2tcnmq --- .../lib/html-spa/src/fileBreadcrumbs.js | 31 ---- .../lib/html-spa/src/filterToggle.js | 50 ------- .../lib/html-spa/src/flattenToggle.js | 25 ---- .../lib/html-spa/src/getChildData.js | 155 -------------------- .../istanbul-reports/lib/html-spa/src/index.js | 160 --------------------- .../istanbul-reports/lib/html-spa/src/routing.js | 52 ------- .../lib/html-spa/src/summaryHeader.js | 63 -------- .../lib/html-spa/src/summaryTableHeader.js | 130 ----------------- .../lib/html-spa/src/summaryTableLine.js | 159 -------------------- 9 files changed, 825 deletions(-) delete mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/fileBreadcrumbs.js delete mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/filterToggle.js delete mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/flattenToggle.js delete mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/getChildData.js delete mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/index.js delete mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/routing.js delete mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryHeader.js delete mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryTableHeader.js delete mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryTableLine.js (limited to 'vanilla/node_modules/istanbul-reports/lib/html-spa/src') diff --git a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/fileBreadcrumbs.js b/vanilla/node_modules/istanbul-reports/lib/html-spa/src/fileBreadcrumbs.js deleted file mode 100644 index b123d37..0000000 --- a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/fileBreadcrumbs.js +++ /dev/null @@ -1,31 +0,0 @@ -const React = require('react'); - -module.exports = function FileBreadcrumbs({ fileFilter = '', setFileFilter }) { - const parts = fileFilter.split('/'); - const breadcrumbs = [ - { - path: '', - name: 'all files' - }, - ...parts.map((part, i) => ({ - path: parts.slice(0, i + 1).join('/'), - name: part - })) - ]; - - return breadcrumbs.map(({ path, name }) => - path === fileFilter ? ( - name - ) : ( - <> - setFileFilter(path)} - > - {name} - - / - - ) - ); -}; diff --git a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/filterToggle.js b/vanilla/node_modules/istanbul-reports/lib/html-spa/src/filterToggle.js deleted file mode 100644 index b636b53..0000000 --- a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/filterToggle.js +++ /dev/null @@ -1,50 +0,0 @@ -const React = require('react'); - -function ToggleOption({ children, filter, activeFilters, setFilters }) { - return ( - - ); -} - -module.exports = function FilterToggle({ activeFilters, setFilters }) { - return ( -
-
Filter:
-
- - Low - - - Medium - - - High - -
-
- ); -}; diff --git a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/flattenToggle.js b/vanilla/node_modules/istanbul-reports/lib/html-spa/src/flattenToggle.js deleted file mode 100644 index 8bb6ea3..0000000 --- a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/flattenToggle.js +++ /dev/null @@ -1,25 +0,0 @@ -const React = require('react'); - -module.exports = function FlattenButton({ setIsFlat, isFlat }) { - return ( -
-
Files:
-
- - -
{' '} -
- ); -}; diff --git a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/getChildData.js b/vanilla/node_modules/istanbul-reports/lib/html-spa/src/getChildData.js deleted file mode 100644 index eff5d31..0000000 --- a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/getChildData.js +++ /dev/null @@ -1,155 +0,0 @@ -function addPath(node, parentPath) { - if (!parentPath) { - return node; - } - return { ...node, file: parentPath + '/' + node.file }; -} - -function flatten(nodes, parentPath) { - let children = []; - for (let i = 0; i < nodes.length; i++) { - const child = nodes[i]; - if (child.children) { - children = [ - ...children, - ...flatten( - child.children, - (parentPath ? parentPath + '/' : '') + child.file - ) - ]; - } else { - children.push(addPath(child, parentPath)); - } - } - return children; -} - -function filterByFile(nodes, fileFilter, parentPath) { - let children = []; - - for (let i = 0; i < nodes.length; i++) { - const child = nodes[i]; - const childFullPath = (parentPath ? parentPath + '/' : '') + child.file; - - const isChildUnderFilter = - fileFilter === childFullPath || - fileFilter.indexOf(childFullPath + '/') === 0; - const isChildAboveFilter = - childFullPath.indexOf(fileFilter + '/') === 0; - - if (isChildUnderFilter) { - // flatten and continue looking underneath - children = [ - ...children, - ...filterByFile(child.children, fileFilter, childFullPath) - ]; - } else if (isChildAboveFilter) { - // remove the parent path and add everything underneath - const charsToRemoveFromFile = - fileFilter.length - (parentPath ? parentPath.length : 0); - let childFilename = child.file.slice(charsToRemoveFromFile); - if (childFilename[0] === '/') { - childFilename = childFilename.slice(1); - } - children.push({ - ...child, - file: childFilename - }); - } - } - return children; -} - -function sort(childData, activeSort) { - const top = activeSort.order === 'asc' ? 1 : -1; - const bottom = activeSort.order === 'asc' ? -1 : 1; - childData.sort((a, b) => { - let valueA; - let valueB; - if (activeSort.sortKey === 'file') { - valueA = a.file; - valueB = b.file; - } else { - const [metricType, valueType] = activeSort.sortKey.split('.'); - valueA = a.metrics[metricType][valueType]; - valueB = b.metrics[metricType][valueType]; - } - - if (valueA === valueB) { - return 0; - } - return valueA < valueB ? top : bottom; - }); - - for (let i = 0; i < childData.length; i++) { - const child = childData[i]; - if (child.children) { - childData[i] = { - ...child, - children: sort(child.children, activeSort) - }; - } - } - return childData; -} - -function filter(nodes, metricsMap, activeFilters) { - const children = []; - for (let i = 0; i < nodes.length; i++) { - let child = nodes[i]; - if (child.children) { - const newSubChildren = filter( - child.children, - metricsMap, - activeFilters - ); - if (newSubChildren.length) { - child = { ...child, children: newSubChildren }; - children.push(child); - } - } else { - if ( - (metricsMap.statements && - activeFilters[child.metrics.statements.classForPercent]) || - (metricsMap.branches && - activeFilters[child.metrics.branches.classForPercent]) || - (metricsMap.functions && - activeFilters[child.metrics.functions.classForPercent]) || - (metricsMap.lines && - activeFilters[child.metrics.lines.classForPercent]) - ) { - children.push(child); - } - } - } - return children; -} - -module.exports = function getChildData( - sourceData, - metricsToShow, - activeSort, - isFlat, - activeFilters, - fileFilter -) { - let childData = sourceData.children; - - if (isFlat) { - childData = flatten(childData.slice(0)); - } - - if (fileFilter) { - childData = filterByFile(childData, fileFilter); - } - - if (activeFilters.low) { - activeFilters = { ...activeFilters, empty: true }; - } - childData = filter(childData, metricsToShow, activeFilters); - - if (activeSort) { - childData = sort(childData, activeSort); - } - return childData; -}; diff --git a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/index.js b/vanilla/node_modules/istanbul-reports/lib/html-spa/src/index.js deleted file mode 100644 index c89c416..0000000 --- a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/index.js +++ /dev/null @@ -1,160 +0,0 @@ -// The index file for the spa running on the summary page -const React = require('react'); -const ReactDOM = require('react-dom'); -const SummaryTableHeader = require('./summaryTableHeader'); -const SummaryTableLine = require('./summaryTableLine'); -const SummaryHeader = require('./summaryHeader'); -const getChildData = require('./getChildData'); -const FlattenToggle = require('./flattenToggle'); -const FilterToggle = require('./filterToggle'); -const FileBreadcrumbs = require('./fileBreadcrumbs'); -const { setLocation, decodeLocation } = require('./routing'); - -const { useState, useMemo, useEffect } = React; - -const sourceData = window.data; -const metricsToShow = {}; -for (let i = 0; i < window.metricsToShow.length; i++) { - metricsToShow[window.metricsToShow[i]] = true; -} - -let firstMount = true; - -function App() { - const routingDefaults = decodeLocation(); - - const [activeSort, setSort] = useState( - (routingDefaults && routingDefaults.activeSort) || { - sortKey: 'file', - order: 'desc' - } - ); - const [isFlat, setIsFlat] = useState( - (routingDefaults && routingDefaults.isFlat) || false - ); - const [activeFilters, setFilters] = useState( - (routingDefaults && routingDefaults.activeFilters) || { - low: true, - medium: true, - high: true - } - ); - const [expandedLines, setExpandedLines] = useState( - (routingDefaults && routingDefaults.expandedLines) || [] - ); - const [fileFilter, setFileFilter] = useState( - (routingDefaults && routingDefaults.fileFilter) || '' - ); - const childData = useMemo( - () => - getChildData( - sourceData, - metricsToShow, - activeSort, - isFlat, - activeFilters, - fileFilter - ), - [activeSort, isFlat, activeFilters, fileFilter] - ); - const overallMetrics = sourceData.metrics; - - useEffect(() => { - setLocation( - firstMount, - activeSort, - isFlat, - activeFilters, - fileFilter, - expandedLines - ); - firstMount = false; - }, [activeSort, isFlat, activeFilters, fileFilter, expandedLines]); - - useEffect(() => { - window.onpopstate = () => { - const routingState = decodeLocation(); - if (routingState) { - // make sure all the state is set before rendering to avoid url updates - // alternative is to merge all the states into one so it can be set in one go - // https://github.com/facebook/react/issues/14259 - ReactDOM.unstable_batchedUpdates(() => { - setFilters(routingState.activeFilters); - setSort(routingState.activeSort); - setIsFlat(routingState.isFlat); - setExpandedLines(routingState.expandedLines); - setFileFilter(routingState.fileFilter); - }); - } - }; - }, []); - - return ( -
-
- -
-
-
-
- -
-
- -
-
-
-
-

- -

-
-
- - { - setSort(newSort); - }} - activeSort={activeSort} - metricsToShow={metricsToShow} - /> - - {childData.map(child => ( - - ))} - -
-
-
- Code coverage generated by{' '} - - istanbul - {' '} - at {window.generatedDatetime} -
-
- ); -} - -ReactDOM.render(, document.getElementById('app')); diff --git a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/routing.js b/vanilla/node_modules/istanbul-reports/lib/html-spa/src/routing.js deleted file mode 100644 index a4d0bc7..0000000 --- a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/routing.js +++ /dev/null @@ -1,52 +0,0 @@ -exports.setLocation = function setLocation( - isReplace, - activeSort, - isFlat, - activeFilters, - fileFilter, - expandedLines -) { - const params = [ - activeSort.sortKey, - activeSort.order, - isFlat, - activeFilters.low, - activeFilters.medium, - activeFilters.high, - encodeURIComponent(fileFilter), - expandedLines.map(encodeURIComponent).join(',') - ]; - const newUrl = `#${params.join('/')}`; - - if (newUrl === location.hash) { - return; - } - - window.history[isReplace ? 'replaceState' : 'pushState'](null, '', newUrl); -}; - -exports.decodeLocation = function decodeLocation() { - const items = location.hash.substr(1).split('/'); - if (items.length !== 8) { - return null; - } - - try { - return { - activeSort: { - sortKey: items[0], - order: items[1] - }, - isFlat: JSON.parse(items[2]), - activeFilters: { - low: JSON.parse(items[3]), - medium: JSON.parse(items[4]), - high: JSON.parse(items[5]) - }, - fileFilter: decodeURIComponent(items[6]), - expandedLines: items[7].split(',').map(decodeURIComponent) - }; - } catch (e) { - return null; - } -}; diff --git a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryHeader.js b/vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryHeader.js deleted file mode 100644 index 3bdd8ff..0000000 --- a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryHeader.js +++ /dev/null @@ -1,63 +0,0 @@ -const React = require('react'); - -function Ignores({ metrics, metricsToShow }) { - const metricKeys = Object.keys(metricsToShow); - const result = []; - - for (let i = 0; i < metricKeys.length; i++) { - const metricKey = metricKeys[i]; - if (metricsToShow[metricKey]) { - const skipped = metrics[metricKey].skipped; - if (skipped > 0) { - result.push( - `${skipped} ${metricKey}${ - skipped === 1 ? '' : metricKey === 'branch' ? 'es' : 's' - }` - ); - } - } - } - - if (result.length === 0) { - return false; - } - - return ( -
- {result.join(', ')} - Ignored -
- ); -} - -function StatusMetric({ data, name }) { - return ( -
- {data.pct}%{' '} - {name}{' '} - - {data.covered}/{data.total} - -
- ); -} - -module.exports = function SummaryHeader({ metrics, metricsToShow }) { - return ( -
- {metricsToShow.statements && ( - - )} - {metricsToShow.branches && ( - - )} - {metricsToShow.functions && ( - - )} - {metricsToShow.lines && ( - - )} - -
- ); -}; diff --git a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryTableHeader.js b/vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryTableHeader.js deleted file mode 100644 index aae91d1..0000000 --- a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryTableHeader.js +++ /dev/null @@ -1,130 +0,0 @@ -const React = require('react'); - -function getSortDetails(sortKey, activeSort) { - let newSort = { sortKey, order: 'desc' }; - let sortClass = ''; - if (activeSort && activeSort.sortKey === sortKey) { - sortClass = 'sorted'; - if (activeSort.order === 'desc') { - sortClass += '-desc'; - newSort.order = 'asc'; - } else { - if (sortKey !== 'file') { - newSort = { sortKey: 'file', order: 'desc' }; - } - } - } - - return { - newSort, - sortClass - }; -} - -function SummaryTableHeaderCell({ name, onSort, sortKey, activeSort }) { - const { newSort, sortClass } = getSortDetails(sortKey, activeSort); - return ( - onSort(newSort)} - > - {name} - - - ); -} - -function FileHeaderCell({ onSort, activeSort }) { - const { newSort, sortClass } = getSortDetails('file', activeSort); - - return ( - onSort(newSort)} - > - File - - - ); -} - -function SubHeadings({ sortKeyPrefix, onSort, activeSort }) { - return ( - <> - - - - - - - ); -} - -module.exports = function SummaryTableHeader({ - onSort, - activeSort, - metricsToShow -}) { - return ( - - - - {metricsToShow.statements && Statements} - {metricsToShow.branches && Branches} - {metricsToShow.functions && Functions} - {metricsToShow.lines && Lines} - - - - {metricsToShow.statements && ( - - )} - {metricsToShow.branches && ( - - )} - {metricsToShow.functions && ( - - )} - {metricsToShow.lines && ( - - )} - - - ); -}; diff --git a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryTableLine.js b/vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryTableLine.js deleted file mode 100644 index 6dc56e6..0000000 --- a/vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryTableLine.js +++ /dev/null @@ -1,159 +0,0 @@ -const React = require('react'); - -function MetricCells({ metrics }) { - const { classForPercent, pct, covered, missed, total } = metrics; - - return ( - <> - {Math.round(pct)}% - -
-
-
- - {covered} - {missed} - {total} - - ); -} - -function FileCell({ - file, - prefix, - expandedLines, - setExpandedLines, - hasChildren, - setFileFilter -}) { - if (hasChildren) { - const expandedIndex = expandedLines.indexOf(prefix + file); - const isExpanded = expandedIndex >= 0; - const newExpandedLines = isExpanded - ? [ - ...expandedLines.slice(0, expandedIndex), - ...expandedLines.slice(expandedIndex + 1) - ] - : [...expandedLines, prefix + file]; - - return ( - <> - - setFileFilter(prefix + file)} - > - {file} - - - ); - } else { - return {file}; - } -} - -function getWorstMetricClassForPercent(metricsToShow, metrics) { - let classForPercent = 'none'; - for (const metricToShow in metricsToShow) { - if (metricsToShow[metricToShow]) { - const metricClassForPercent = metrics[metricToShow].classForPercent; - - // ignore none metrics so they don't change whats shown - if (metricClassForPercent === 'none') { - continue; - } - - // if the metric low or lower than whats currently being used, replace it - if ( - metricClassForPercent == 'low' || - (metricClassForPercent === 'medium' && - classForPercent !== 'low') || - (metricClassForPercent === 'high' && - classForPercent !== 'low' && - classForPercent !== 'medium') - ) { - classForPercent = metricClassForPercent; - } - } - } - return classForPercent; -} - -module.exports = function SummaryTableLine({ - prefix, - metrics, - file, - children, - tabSize, - metricsToShow, - expandedLines, - setExpandedLines, - fileFilter, - setFileFilter -}) { - tabSize = tabSize || 0; - if (children && tabSize > 0) { - tabSize--; - } - prefix = (fileFilter ? fileFilter + '/' : '') + (prefix || ''); - - return ( - <> - - - {/* eslint-disable-line prefer-spread */ Array.apply(null, { - length: tabSize - }).map((nothing, index) => ( - - ))} - - - {metricsToShow.statements && ( - - )} - {metricsToShow.branches && ( - - )} - {metricsToShow.functions && ( - - )} - {metricsToShow.lines && } - - {children && - expandedLines.indexOf(prefix + file) >= 0 && - children.map(child => ( - - ))} - - ); -}; -- cgit v1.2.3