mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-26 06:37:07 +00:00
feat(frontend): add the perfect-design theme, shell and helpers
Install @perfect-design/ui 0.3.10 with the workbench style pack, IBM Plex faces and the inline theme boot script. The app shell uses AppHeader, AppShell and SidebarNav. Shared formatters, severity tones and icon data replace the per-view copies. A test checks that main.css scans only the library directories the app imports.
This commit is contained in:
+46
-58
@@ -1,61 +1,49 @@
|
||||
<template>
|
||||
<div class="min-h-screen bg-background">
|
||||
<nav class="sticky top-0 z-50 bg-card/95 backdrop-blur-lg shadow-sm border-b">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="flex justify-between h-16">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="flex items-center justify-center w-10 h-10 rounded-lg bg-primary text-primary-foreground">
|
||||
<i class="fas fa-box-open text-lg"></i>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<h1 class="text-lg font-semibold tracking-tight text-foreground">GoHoarder</h1>
|
||||
<p class="text-xs text-muted-foreground">Package Cache Manager</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-1">
|
||||
<router-link
|
||||
to="/"
|
||||
class="inline-flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium text-foreground/70 hover:text-foreground hover:bg-accent transition-colors"
|
||||
active-class="text-foreground bg-accent"
|
||||
>
|
||||
<i class="fas fa-chart-pie text-sm"></i>
|
||||
<span>Dashboard</span>
|
||||
</router-link>
|
||||
<router-link
|
||||
to="/packages"
|
||||
class="inline-flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium text-foreground/70 hover:text-foreground hover:bg-accent transition-colors"
|
||||
active-class="text-foreground bg-accent"
|
||||
>
|
||||
<i class="fas fa-boxes text-sm"></i>
|
||||
<span>Packages</span>
|
||||
</router-link>
|
||||
<router-link
|
||||
to="/stats"
|
||||
class="inline-flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium text-foreground/70 hover:text-foreground hover:bg-accent transition-colors"
|
||||
active-class="text-foreground bg-accent"
|
||||
>
|
||||
<i class="fas fa-chart-bar text-sm"></i>
|
||||
<span>Statistics</span>
|
||||
</router-link>
|
||||
<router-link
|
||||
to="/admin/bypasses"
|
||||
class="inline-flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium text-foreground/70 hover:text-foreground hover:bg-accent transition-colors"
|
||||
active-class="text-foreground bg-accent"
|
||||
>
|
||||
<i class="fas fa-shield-alt text-sm"></i>
|
||||
<span>Admin</span>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue'
|
||||
import { RouterView } from 'vue-router'
|
||||
import { AppHeader, AppShell, Icon, ThemeToggle, Toaster, useThemeStore } from '@perfect-design/ui'
|
||||
import AppNav from '@/components/shell/AppNav.vue'
|
||||
import { faBoxOpen } from '@/lib/icons'
|
||||
|
||||
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10">
|
||||
<router-view />
|
||||
</main>
|
||||
// init() installs the watcher that applies and persists the choice; the style is set after it so a stored value cannot override the pack.
|
||||
onMounted(() => {
|
||||
const theme = useThemeStore()
|
||||
theme.init()
|
||||
theme.setStyle('workbench')
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex min-h-dvh flex-col">
|
||||
<!-- Rendered here, not by AppShell: the header sits above the shell, and the skip link must be the first tab stop. -->
|
||||
<a
|
||||
href="#main-content"
|
||||
class="sr-only focus:not-sr-only focus:absolute focus:start-2 focus:top-2 focus:z-(--z-toast) focus:rounded-md focus:bg-primary focus:px-3 focus:py-2 focus:text-sm focus:text-primary-foreground"
|
||||
>Skip to main content</a
|
||||
>
|
||||
<!-- AppShell wraps its #header slot in its own <header> and AppHeader renders one too; outside the shell there is one banner. -->
|
||||
<AppHeader sticky mobile-variant="sheet" class="[&>div]:h-(--header-h)">
|
||||
<template #brand>
|
||||
<Icon :icon="faBoxOpen" size="lg" class="text-primary" />
|
||||
<p class="m-0 text-lg font-semibold">GoHoarder</p>
|
||||
<p class="m-0 hidden text-sm text-muted-foreground sm:block">Package cache manager</p>
|
||||
</template>
|
||||
<template #actions><ThemeToggle /></template>
|
||||
<template #mobile><AppNav sheet /></template>
|
||||
</AppHeader>
|
||||
|
||||
<!-- The aside scrolls itself, so only the aside can stick; both offsets come from --header-h. -->
|
||||
<AppShell
|
||||
:skip-link="false"
|
||||
drawer-breakpoint="md"
|
||||
sidebar-label="Sections"
|
||||
content-max-width="7xl"
|
||||
class="flex-1 md:[&_[data-slot=app-shell-sidebar]]:sticky md:[&_[data-slot=app-shell-sidebar]]:top-(--header-h) md:[&_[data-slot=app-shell-sidebar]]:h-[calc(100dvh-var(--header-h))] md:[&_[data-slot=app-shell-sidebar]]:self-start"
|
||||
>
|
||||
<template #sidebar><AppNav /></template>
|
||||
<div class="py-6"><RouterView /></div>
|
||||
</AppShell>
|
||||
|
||||
<Toaster />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// App component
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { RouterLink, useRoute } from 'vue-router'
|
||||
import { SidebarNav, type SidebarNavGroup } from '@perfect-design/ui'
|
||||
import {
|
||||
faBoxesStacked,
|
||||
faChartColumn,
|
||||
faChartPie,
|
||||
faShieldHalved,
|
||||
faTriangleExclamation,
|
||||
} from '@/lib/icons'
|
||||
|
||||
// The sidebar slot of AppShell hides itself below md and the header's mobile slot only shows below md,
|
||||
// so each placement renders one nav and the two never compete for the same viewport.
|
||||
defineProps<{ readonly sheet?: boolean }>()
|
||||
|
||||
const GROUPS: SidebarNavGroup[] = [
|
||||
{
|
||||
items: [
|
||||
{ label: 'Dashboard', to: '/', icon: faChartPie },
|
||||
{ label: 'Packages', to: '/packages', icon: faBoxesStacked },
|
||||
{ label: 'Vulnerable', to: '/vulnerable-packages', icon: faTriangleExclamation },
|
||||
{ label: 'Bypasses', to: '/admin/bypasses', icon: faShieldHalved },
|
||||
{ label: 'Stats', to: '/stats', icon: faChartColumn },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const SECTION_PREFIXES: ReadonlyArray<readonly [string, string]> = [
|
||||
['/packages', '/packages'],
|
||||
['/package/', '/packages'],
|
||||
['/vulnerable-packages', '/vulnerable-packages'],
|
||||
['/blocked-packages', '/vulnerable-packages'],
|
||||
['/admin/bypasses', '/admin/bypasses'],
|
||||
['/stats', '/stats'],
|
||||
]
|
||||
|
||||
const route = useRoute()
|
||||
const current = computed(() => SECTION_PREFIXES.find(([prefix]) => route.path.startsWith(prefix))?.[1] ?? '/')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SidebarNav
|
||||
:groups="GROUPS"
|
||||
:current="current"
|
||||
:link-as="RouterLink"
|
||||
:label="sheet ? 'Sections menu' : 'Sections'"
|
||||
class="w-full p-3"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,22 @@
|
||||
const BYTE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB']
|
||||
const BYTES_PER_UNIT = 1024
|
||||
|
||||
export function formatNumber(num: number): string {
|
||||
return new Intl.NumberFormat().format(num)
|
||||
}
|
||||
|
||||
export function formatBytes(bytes: number): string {
|
||||
if (bytes === 0) return '0 B'
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(BYTES_PER_UNIT))
|
||||
return Math.round((bytes / Math.pow(BYTES_PER_UNIT, i)) * 100) / 100 + ' ' + BYTE_UNITS[i]
|
||||
}
|
||||
|
||||
export function formatDate(date: string): string {
|
||||
if (!date) return 'N/A'
|
||||
const parsed = new Date(date)
|
||||
return Number.isNaN(parsed.getTime()) ? date : parsed.toLocaleString()
|
||||
}
|
||||
|
||||
export function withVersionPrefix(version: string): string {
|
||||
return version.startsWith('v') ? version : 'v' + version
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
export {
|
||||
faArrowLeft,
|
||||
faBan,
|
||||
faBox,
|
||||
faBoxOpen,
|
||||
faBoxesStacked,
|
||||
faChartColumn,
|
||||
faChartLine,
|
||||
faChartPie,
|
||||
faDownload,
|
||||
faHardDrive,
|
||||
faPen,
|
||||
faShieldHalved,
|
||||
faTrash,
|
||||
faTriangleExclamation,
|
||||
} from '@fortawesome/free-solid-svg-icons'
|
||||
export {
|
||||
faCircleCheck,
|
||||
faMagnifyingGlass,
|
||||
faPlus,
|
||||
faRotateRight,
|
||||
faChevronDown,
|
||||
faChevronUp,
|
||||
} from '@perfect-design/ui/lib/icons'
|
||||
@@ -0,0 +1,33 @@
|
||||
import type { VulnerabilityCounts } from '@/stores/packages'
|
||||
|
||||
export type SeverityTone = 'danger' | 'warning' | 'info' | 'neutral'
|
||||
|
||||
export const SEVERITY_TONES: Record<string, SeverityTone> = {
|
||||
critical: 'danger',
|
||||
high: 'warning',
|
||||
moderate: 'info',
|
||||
medium: 'info',
|
||||
low: 'neutral',
|
||||
}
|
||||
|
||||
export const SEVERITY_RANK: Record<string, number> = {
|
||||
critical: 4,
|
||||
high: 3,
|
||||
moderate: 2,
|
||||
medium: 2,
|
||||
low: 1,
|
||||
}
|
||||
|
||||
export const SEVERITY_LEVELS = ['critical', 'high', 'moderate', 'low'] as const
|
||||
export type SeverityLevel = (typeof SEVERITY_LEVELS)[number]
|
||||
|
||||
export const NO_VULNERABILITIES: VulnerabilityCounts = { critical: 0, high: 0, moderate: 0, low: 0 }
|
||||
|
||||
export function severityRank(severity: string): number {
|
||||
return SEVERITY_RANK[severity.toLowerCase()] ?? 0
|
||||
}
|
||||
|
||||
export function formatSeverityName(severity: string): string {
|
||||
const lower = severity.toLowerCase()
|
||||
return lower.charAt(0).toUpperCase() + lower.slice(1)
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import { configureStrictMode } from '@perfect-design/ui'
|
||||
import router from './router'
|
||||
import App from './App.vue'
|
||||
import './styles/main.css'
|
||||
|
||||
configureStrictMode(import.meta.env.DEV ? 'throw' : 'warn')
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
app.use(createPinia())
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import Dashboard from '../components/Dashboard.vue'
|
||||
import PackageList from '../components/PackageList.vue'
|
||||
import PackageDetails from '../components/PackageDetails.vue'
|
||||
import Stats from '../components/Stats.vue'
|
||||
import VulnerablePackages from '../components/VulnerablePackages.vue'
|
||||
import BypassManagementPanel from '../components/BypassManagementPanel.vue'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
@@ -12,40 +6,40 @@ const router = createRouter({
|
||||
{
|
||||
path: '/',
|
||||
name: 'dashboard',
|
||||
component: Dashboard,
|
||||
component: () => import('../components/Dashboard.vue'),
|
||||
},
|
||||
{
|
||||
path: '/packages/:registry?',
|
||||
name: 'packages',
|
||||
component: PackageList,
|
||||
component: () => import('../components/PackageList.vue'),
|
||||
props: true,
|
||||
},
|
||||
{
|
||||
// Separate route for package details - supports names with slashes (Go packages)
|
||||
path: '/package/:registry/:name+/:version',
|
||||
name: 'package-details',
|
||||
component: PackageDetails,
|
||||
component: () => import('../components/PackageDetails.vue'),
|
||||
props: true,
|
||||
},
|
||||
{
|
||||
path: '/stats',
|
||||
name: 'stats',
|
||||
component: Stats,
|
||||
component: () => import('../components/Stats.vue'),
|
||||
},
|
||||
{
|
||||
path: '/vulnerable-packages',
|
||||
name: 'vulnerable-packages',
|
||||
component: VulnerablePackages,
|
||||
component: () => import('../components/VulnerablePackages.vue'),
|
||||
},
|
||||
{
|
||||
path: '/blocked-packages',
|
||||
name: 'blocked-packages',
|
||||
component: VulnerablePackages,
|
||||
component: () => import('../components/VulnerablePackages.vue'),
|
||||
},
|
||||
{
|
||||
path: '/admin/bypasses',
|
||||
name: 'bypasses',
|
||||
component: BypassManagementPanel,
|
||||
component: () => import('../components/BypassManagementPanel.vue'),
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
+118
-80
@@ -1,83 +1,121 @@
|
||||
@import '@fortawesome/fontawesome-free/css/all.min.css';
|
||||
@import "tailwindcss";
|
||||
@import "@perfect-design/ui/theme.css";
|
||||
@import "@perfect-design/ui/packs/workbench.css";
|
||||
/* Only the library components the app imports, plus their transitive imports: scanning all of dist adds every component's classes. `pnpm sources` regenerates this list. */
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/data-display/ActivityFeed/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/data-display/BarChart/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/data-display/Card/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/data-display/CodeViewer/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/data-display/CodeViewer/tokenize/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/data-display/DataTable/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/data-display/DescriptionList/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/data-display/KpiTile/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/data-display/Sparkline/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/data-display/StatGroup/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/data-display/Table/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/data-display/_chart/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/data-display/_shared/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/feedback/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/feedback/Alert/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/feedback/ConfirmDialog/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/feedback/EmptyState/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/feedback/ErrorState/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/feedback/LoadingState/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/feedback/ToastItem/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/feedback/Toaster/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/forms/Checkbox/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/forms/CheckboxCard/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/forms/Combobox/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/forms/Field/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/forms/Input/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/forms/InputGroup/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/forms/Label/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/forms/NativeSelect/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/forms/SearchInput/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/forms/SegmentedControl/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/forms/Textarea/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/layout/AppShell/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/layout/ConfigProvider/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/layout/Container/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/layout/PageHeader/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/navigation/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/navigation/Accordion/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/navigation/AppHeader/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/navigation/MobileNav/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/navigation/NavLink/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/navigation/Pagination/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/navigation/SidebarNav/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/navigation/ThemeToggle/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/overlays/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/overlays/AlertDialog/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/overlays/Dialog/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/Avatar/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/Badge/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/Button/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/Icon/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/IconButton/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/Link/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/ScrollArea/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/Spinner/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/StatusBadge/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/StatusDot/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/typography/Markdown/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/typography/Markdown/parse/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/components/typography/RelativeTime/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/lib/*.js";
|
||||
@source "../../node_modules/@perfect-design/ui/dist/stores/*.js";
|
||||
|
||||
@import 'tailwindcss';
|
||||
@config '../../tailwind.config.js';
|
||||
@custom-variant dark (&:is(.dark *));
|
||||
|
||||
@layer base {
|
||||
:root {
|
||||
/* Tailwind slate-50 for background */
|
||||
--background: 210 40% 98%;
|
||||
/* Tailwind slate-900 for foreground */
|
||||
--foreground: 222 47% 11%;
|
||||
/* White for cards */
|
||||
--card: 0 0% 100%;
|
||||
--card-foreground: 222 47% 11%;
|
||||
--popover: 0 0% 100%;
|
||||
--popover-foreground: 222 47% 11%;
|
||||
/* Tailwind slate-700 for primary */
|
||||
--primary: 215 25% 27%;
|
||||
--primary-foreground: 0 0% 100%;
|
||||
/* Tailwind slate-100 for secondary */
|
||||
--secondary: 210 40% 96%;
|
||||
--secondary-foreground: 222 47% 11%;
|
||||
/* Tailwind slate-100 for muted */
|
||||
--muted: 210 40% 96%;
|
||||
/* Tailwind slate-500 for muted-foreground */
|
||||
--muted-foreground: 215 20% 65%;
|
||||
--accent: 210 40% 96%;
|
||||
--accent-foreground: 222 47% 11%;
|
||||
/* Tailwind red-500 for destructive */
|
||||
--destructive: 0 84% 60%;
|
||||
--destructive-foreground: 0 0% 98%;
|
||||
/* Tailwind slate-200 for border */
|
||||
--border: 214 32% 91%;
|
||||
--input: 214 32% 91%;
|
||||
/* Tailwind slate-700 for ring */
|
||||
--ring: 215 25% 27%;
|
||||
/* Chart colors using Tailwind palette with slate base */
|
||||
--chart-1: 215 25% 27%;
|
||||
--chart-2: 200 98% 39%;
|
||||
--chart-3: 142 71% 45%;
|
||||
--chart-4: 25 95% 53%;
|
||||
--chart-5: 262 83% 58%;
|
||||
--radius: 0.75rem;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: 222 47% 11%;
|
||||
--foreground: 210 40% 98%;
|
||||
--card: 222 47% 11%;
|
||||
--card-foreground: 210 40% 98%;
|
||||
--popover: 222 47% 11%;
|
||||
--popover-foreground: 210 40% 98%;
|
||||
--primary: 200 98% 39%;
|
||||
--primary-foreground: 0 0% 100%;
|
||||
--secondary: 217 33% 17%;
|
||||
--secondary-foreground: 210 40% 98%;
|
||||
--muted: 217 33% 17%;
|
||||
--muted-foreground: 215 20% 65%;
|
||||
--accent: 217 33% 17%;
|
||||
--accent-foreground: 210 40% 98%;
|
||||
--destructive: 0 84% 60%;
|
||||
--destructive-foreground: 0 0% 98%;
|
||||
--border: 217 33% 17%;
|
||||
--input: 217 33% 17%;
|
||||
--ring: 200 98% 39%;
|
||||
--chart-1: 200 98% 39%;
|
||||
--chart-2: 142 71% 45%;
|
||||
--chart-3: 262 83% 58%;
|
||||
--chart-4: 25 95% 53%;
|
||||
--chart-5: 340 82% 52%;
|
||||
}
|
||||
|
||||
* {
|
||||
@apply border-border;
|
||||
}
|
||||
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
/* woff2 and Latin only: one file per face the interface uses. */
|
||||
@font-face {
|
||||
font-family: "IBM Plex Sans";
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
font-weight: 400;
|
||||
src: url("../../node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "IBM Plex Sans";
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
font-weight: 500;
|
||||
src: url("../../node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "IBM Plex Sans";
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
font-weight: 600;
|
||||
src: url("../../node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "IBM Plex Mono";
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
font-weight: 400;
|
||||
src: url("../../node_modules/@fontsource/ibm-plex-mono/files/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
|
||||
}
|
||||
|
||||
/* Custom component styles have been replaced with shadcn-vue components */
|
||||
@theme {
|
||||
--font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
|
||||
--font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
|
||||
}
|
||||
|
||||
/* AppHeader's bar height (its default h-14) and the sidebar's sticky offset. */
|
||||
:root {
|
||||
--header-h: calc(var(--spacing) * 14);
|
||||
}
|
||||
|
||||
html {
|
||||
scroll-padding-top: calc(var(--header-h) + var(--spacing) * 2);
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
animation-duration: 0.01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.01ms !important;
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// @vitest-environment node
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import css from './main.css?raw'
|
||||
import { librarySources } from '../../scripts/library-sources.mjs'
|
||||
|
||||
const root = new URL('../..', import.meta.url).pathname
|
||||
|
||||
describe('main.css', () => {
|
||||
it('imports the library theme and the workbench pack', () => {
|
||||
expect(css).toContain('@import "@perfect-design/ui/theme.css"')
|
||||
expect(css).toContain('@import "@perfect-design/ui/packs/workbench.css"')
|
||||
})
|
||||
|
||||
it('scans only the library directories the app imports (run `pnpm sources` after changing imports)', () => {
|
||||
const declared = css.split('\n').filter((line: string) => line.startsWith('@source '))
|
||||
expect(declared).toEqual(librarySources(root))
|
||||
expect(css).not.toMatch(/@source "[^"]*\/dist"/)
|
||||
})
|
||||
|
||||
it('loads the Plex faces as Latin woff2 only', () => {
|
||||
const urls = [...css.matchAll(/url\("([^"]+)"\)/g)].map((m) => m[1])
|
||||
expect(urls.length).toBe(4)
|
||||
for (const url of urls) expect(url).toMatch(/-latin-\d{3}-normal\.woff2$/)
|
||||
})
|
||||
|
||||
it('shares one header height token with the scroll offset', () => {
|
||||
expect(css).toMatch(/--header-h:/)
|
||||
expect(css).toMatch(/scroll-padding-top:\s*calc\(var\(--header-h\)/)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,160 @@
|
||||
import type { Package, Stats } from '@/stores/packages'
|
||||
|
||||
export const STATS: Stats = {
|
||||
registry: '',
|
||||
total_packages: 4,
|
||||
total_size: 5368709120,
|
||||
max_cache_size: 10737418240,
|
||||
total_downloads: 120,
|
||||
scanned_packages: 3,
|
||||
vulnerable_packages: 2,
|
||||
blocked_packages: 1,
|
||||
}
|
||||
|
||||
export const REGISTRIES = {
|
||||
npm: { count: 2, size: 2147483648, downloads: 80 },
|
||||
pypi: { count: 1, size: 1073741824, downloads: 30 },
|
||||
go: { count: 1, size: 2147483648, downloads: 10 },
|
||||
}
|
||||
|
||||
export const PACKAGES: Package[] = [
|
||||
{
|
||||
id: 'npm-1',
|
||||
registry: 'npm',
|
||||
name: 'left-pad',
|
||||
version: '1.3.0',
|
||||
size: 2048,
|
||||
cached_at: '2026-01-03T10:00:00Z',
|
||||
last_accessed: '2026-01-03T10:00:00Z',
|
||||
download_count: 40,
|
||||
vulnerabilities: {
|
||||
scanned: true,
|
||||
status: 'vulnerable',
|
||||
counts: { critical: 1, high: 2, moderate: 0, low: 1 },
|
||||
total: 4,
|
||||
scannedAt: '2026-01-03T10:05:00Z',
|
||||
isBlocked: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'npm-2',
|
||||
registry: 'npm',
|
||||
name: 'left-pad',
|
||||
version: '1.2.0',
|
||||
size: 1024,
|
||||
cached_at: '2026-01-02T10:00:00Z',
|
||||
last_accessed: '2026-01-02T10:00:00Z',
|
||||
download_count: 40,
|
||||
vulnerabilities: {
|
||||
scanned: true,
|
||||
status: 'vulnerable',
|
||||
counts: { critical: 0, high: 0, moderate: 3, low: 0 },
|
||||
total: 3,
|
||||
scannedAt: '2026-01-02T10:05:00Z',
|
||||
isBlocked: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'pypi-1',
|
||||
registry: 'pypi',
|
||||
name: 'requests',
|
||||
version: '2.31.0',
|
||||
size: 4096,
|
||||
cached_at: '2026-01-01T10:00:00Z',
|
||||
last_accessed: '2026-01-01T10:00:00Z',
|
||||
download_count: 30,
|
||||
vulnerabilities: { scanned: true, status: 'clean', total: 0, scannedAt: '2026-01-01T10:05:00Z' },
|
||||
},
|
||||
{
|
||||
id: 'go-1',
|
||||
registry: 'go',
|
||||
name: 'github.com/example/module',
|
||||
version: 'v0.4.1',
|
||||
size: 512,
|
||||
cached_at: '2026-01-04T10:00:00Z',
|
||||
last_accessed: '2026-01-04T10:00:00Z',
|
||||
download_count: 10,
|
||||
vulnerabilities: { scanned: false, status: 'not_scanned' },
|
||||
},
|
||||
]
|
||||
|
||||
export const TIMESERIES = {
|
||||
period: '1day',
|
||||
registry: '',
|
||||
data_points: [
|
||||
{ timestamp: '2026-01-04T08:00:00Z', value: 3 },
|
||||
{ timestamp: '2026-01-04T09:00:00Z', value: 7 },
|
||||
{ timestamp: '2026-01-04T10:00:00Z', value: 5 },
|
||||
],
|
||||
}
|
||||
|
||||
export const VULNERABILITY_REPORT = {
|
||||
scanned: true,
|
||||
scanner: 'trivy+osv',
|
||||
scanned_at: '2026-01-03T10:05:00Z',
|
||||
status: 'vulnerable',
|
||||
vulnerability_count: 3,
|
||||
bypassed_count: 1,
|
||||
severity_counts: { critical: 1, high: 1, moderate: 0, low: 1 },
|
||||
vulnerabilities: [
|
||||
{
|
||||
id: 'CVE-2026-0001',
|
||||
severity: 'LOW',
|
||||
title: 'Low severity sample',
|
||||
description: 'A **low** severity sample description.',
|
||||
references: ['https://example.com/advisory/1'],
|
||||
fixed_in: '1.3.1',
|
||||
bypassed: false,
|
||||
},
|
||||
{
|
||||
id: 'CVE-2026-0002',
|
||||
severity: 'CRITICAL',
|
||||
title: 'Critical severity sample',
|
||||
description: 'A critical severity sample description.',
|
||||
references: [],
|
||||
fixed_in: '',
|
||||
bypassed: true,
|
||||
bypass: {
|
||||
id: 'bypass-1',
|
||||
reason: 'No fix available',
|
||||
created_by: '[email protected]',
|
||||
expires_at: '2026-02-01T00:00:00Z',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'CVE-2026-0003',
|
||||
severity: 'HIGH',
|
||||
title: '',
|
||||
description: 'A high severity sample description.',
|
||||
references: [],
|
||||
fixed_in: '2.0.0',
|
||||
bypassed: false,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
export const BYPASSES = [
|
||||
{
|
||||
id: 'bypass-1',
|
||||
type: 'cve',
|
||||
target: 'CVE-2026-0002',
|
||||
reason: 'No fix available',
|
||||
created_by: '[email protected]',
|
||||
created_at: '2026-01-01T00:00:00Z',
|
||||
expires_at: '2099-01-01T00:00:00Z',
|
||||
applies_to: 'npm/[email protected]',
|
||||
notify_on_expiry: true,
|
||||
active: true,
|
||||
},
|
||||
{
|
||||
id: 'bypass-2',
|
||||
type: 'package',
|
||||
target: 'npm/left-pad',
|
||||
reason: 'Pinned until the next release',
|
||||
created_by: '[email protected]',
|
||||
created_at: '2025-01-01T00:00:00Z',
|
||||
expires_at: '2025-02-01T00:00:00Z',
|
||||
notify_on_expiry: false,
|
||||
active: false,
|
||||
},
|
||||
]
|
||||
@@ -0,0 +1,14 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { defineComponent, h } from 'vue'
|
||||
import { Input } from '@perfect-design/ui'
|
||||
import { mountStrict } from './mountStrict'
|
||||
|
||||
describe('mountStrict', () => {
|
||||
it('reports a library contract violation, so an empty list in a smoke test means something', async () => {
|
||||
const Unnamed = defineComponent({ render: () => h(Input) })
|
||||
const { problems, restore } = await mountStrict(Unnamed)
|
||||
restore()
|
||||
expect(problems.length).toBeGreaterThan(0)
|
||||
expect(problems.join(' ')).toMatch(/accessible name/i)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,37 @@
|
||||
import { configureStrictMode } from '@perfect-design/ui'
|
||||
import { flushPromises, mount, type ComponentMountingOptions } from '@vue/test-utils'
|
||||
import { vi } from 'vitest'
|
||||
import type { Component } from 'vue'
|
||||
|
||||
/**
|
||||
* Mounts under strict mode 'throw' and returns every Vue warning, Vue error and library ContractError seen,
|
||||
* so a smoke test can assert the list is empty. The library runs its contract checks from async onMounted hooks.
|
||||
*/
|
||||
export async function mountStrict(component: Component, options: ComponentMountingOptions<any> = {}) {
|
||||
configureStrictMode('throw')
|
||||
const problems: string[] = []
|
||||
const record = (kind: string) => (err: unknown) => {
|
||||
problems.push(`${kind}: ${err instanceof Error ? err.message : String(err)}`)
|
||||
}
|
||||
const warn = vi.spyOn(console, 'warn').mockImplementation((...args) => record('warn')(args.join(' ')))
|
||||
const error = vi.spyOn(console, 'error').mockImplementation((...args) => record('error')(args.join(' ')))
|
||||
|
||||
const wrapper = mount(component, {
|
||||
attachTo: document.body,
|
||||
...options,
|
||||
global: {
|
||||
...options.global,
|
||||
config: { errorHandler: record('error'), warnHandler: record('warn') },
|
||||
},
|
||||
})
|
||||
await flushPromises()
|
||||
await new Promise((resolve) => setTimeout(resolve, 0))
|
||||
await flushPromises()
|
||||
|
||||
const restore = () => {
|
||||
wrapper.unmount()
|
||||
warn.mockRestore()
|
||||
error.mockRestore()
|
||||
}
|
||||
return { wrapper, problems, restore }
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { createMemoryHistory, createRouter, type Router } from 'vue-router'
|
||||
import { defineComponent, h } from 'vue'
|
||||
|
||||
const Stub = defineComponent({ render: () => h('div') })
|
||||
|
||||
export const ROUTE_PATHS = [
|
||||
'/',
|
||||
'/packages/:registry?',
|
||||
'/package/:registry/:name+/:version',
|
||||
'/stats',
|
||||
'/vulnerable-packages',
|
||||
'/blocked-packages',
|
||||
'/admin/bypasses',
|
||||
]
|
||||
|
||||
export async function createTestRouter(initial = '/'): Promise<Router> {
|
||||
const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: ROUTE_PATHS.map((path) => ({ path, component: Stub })),
|
||||
})
|
||||
await router.push(initial)
|
||||
await router.isReady()
|
||||
return router
|
||||
}
|
||||
Reference in New Issue
Block a user