refactor: optimize internal library dependencies and resolve lint warnings

This commit is contained in:
N1C4T
2026-02-23 15:43:16 +04:00
parent 3934ec0650
commit 6e4ff0b79e
9 changed files with 13 additions and 42 deletions

View File

@@ -272,6 +272,7 @@ export default function Home() {
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
<div className="header-animate">
<div className="flex items-center gap-4">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src="/tuxmate.png"
alt="TuxMate Logo"

View File

@@ -2,7 +2,6 @@
import { useState } from 'react';
// Shows distro icon, falls back to first letter if image fails
export function DistroIcon({ url, name, size = 20 }: { url: string; name: string; size?: number }) {
const [error, setError] = useState(false);

View File

@@ -7,7 +7,6 @@ import { distros, type DistroId } from '@/lib/data';
import { analytics } from '@/lib/analytics';
import { DistroIcon } from './DistroIcon';
// Distro picker dropdown.
export function DistroSelector({
selectedDistro,
onSelect

View File

@@ -419,7 +419,6 @@ export function Sidebar({
<div className="flex items-center justify-between">
<ThemeToggle />
{/* Links */}
<div className="flex items-center gap-0.5">
<a
href="https://github.com/abusoww/tuxmate"

View File

@@ -1,5 +1,4 @@
// Umami Analytics Utility
// https://umami.is/docs/track-events
declare global {
interface Window {
@@ -9,7 +8,6 @@ declare global {
}
}
// Safe wrapper - works even if Umami hasn't loaded yet
export function track(
eventName: string,
eventData?: Record<string, string | number | boolean>
@@ -19,25 +17,18 @@ export function track(
}
}
// Event names for the Umami dashboard
export const EVENTS = {
// Distro Selection
DISTRO_SELECTED: 'Distro Selected',
// App Interactions
APP_SELECTED: 'App Selected',
APP_DESELECTED: 'App Deselected',
// Command Actions
COMMAND_COPIED: 'Command Copied',
SCRIPT_DOWNLOADED: 'Script Downloaded',
// Navigation
GITHUB_CLICKED: 'GitHub Clicked',
CONTRIBUTE_CLICKED: 'Contribute Clicked',
// UI Interactions
HELP_OPENED: 'How It Works Opened',
HELP_CLOSED: 'How It Works Closed',
THEME_CHANGED: 'Theme Changed',
@@ -45,8 +36,6 @@ export const EVENTS = {
CATEGORY_COLLAPSED: 'Category Collapsed',
} as const;
// Helper functions so we don't have to remember event names
export const analytics = {
distroSelected: (distro: string) => {
track(EVENTS.DISTRO_SELECTED, { distro });

View File

@@ -1,16 +1,9 @@
// AUR package detection for Arch users
// Identifies packages that come from the AUR vs official repos
import aurPackages from './aur-packages.json';
// Suffixes that scream "I'm from the AUR"
export const AUR_PATTERNS = ['-bin', '-git', '-appimage'];
// Known AUR packages without standard suffixes
// Extracted to JSON for cleaner code
export const KNOWN_AUR_PACKAGES = new Set(aurPackages.packages);
// Check if a package name is an AUR package
export function isAurPackage(packageName: string): boolean {
if (KNOWN_AUR_PACKAGES.has(packageName)) {
return true;

View File

@@ -1,6 +1,3 @@
// Main entry point for generating install scripts.
// Each distro has its own module - keeps things sane.
import { distros, type DistroId } from './data';
import {
getSelectedPackages,
@@ -15,14 +12,13 @@ import {
generateHomebrewScript,
} from './scripts';
interface ScriptOptions {
interface GenerateOptions {
distroId: DistroId;
selectedAppIds: Set<string>;
helper?: 'yay' | 'paru';
}
// Full install script for download. Nix gets a config file, others get shell scripts.
export function generateInstallScript(options: ScriptOptions): string {
export function generateInstallScript(options: GenerateOptions): string {
const { distroId, selectedAppIds, helper = 'yay' } = options;
const distro = distros.find(d => d.id === distroId);
@@ -45,8 +41,8 @@ export function generateInstallScript(options: ScriptOptions): string {
}
}
// Quick one-liner for copy-paste warriors
export function generateSimpleCommand(selectedAppIds: Set<string>, distroId: DistroId): string {
export function generateCommandline(options: GenerateOptions): string {
const { selectedAppIds, distroId } = options;
const packages = getSelectedPackages(selectedAppIds, distroId);
if (packages.length === 0) return '# No packages selected';

View File

@@ -1,22 +1,17 @@
// Nix unfree package detection - these require allowUnfree = true
import nixUnfreeList from './nix-unfree.json';
import unfreeData from './nix-unfree.json';
// Loaded from JSON source
export const KNOWN_UNFREE_PACKAGES = new Set(unfreeData.packages);
const UNFREE_PACKAGES = new Set(nixUnfreeList.packages);
export function isUnfreePackage(pkg: string): boolean {
const cleanPkg = pkg.trim().toLowerCase();
// Direct match
if (KNOWN_UNFREE_PACKAGES.has(cleanPkg)) return true;
if (UNFREE_PACKAGES.has(cleanPkg)) return true;
// Nested packages like jetbrains.idea-ultimate
// We iterate because the set is small (matches original logic)
for (const unfree of KNOWN_UNFREE_PACKAGES) {
if (cleanPkg.includes(unfree)) return true;
for (const unfreePkg of Array.from(UNFREE_PACKAGES)) {
if (cleanPkg.includes(unfreePkg)) return true;
}
return false;
}

View File

@@ -1,4 +1,4 @@
// Re-exports all distro script generators
export { escapeShellString, getSelectedPackages, type PackageInfo } from './shared';
export { generateUbuntuScript } from './ubuntu';