mirror of
https://github.com/abusoww/tuxmate.git
synced 2026-04-17 15:53:24 +02:00
refactor: optimize internal library dependencies and resolve lint warnings
This commit is contained in:
@@ -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="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
||||||
<div className="header-animate">
|
<div className="header-animate">
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||||
<img
|
<img
|
||||||
src="/tuxmate.png"
|
src="/tuxmate.png"
|
||||||
alt="TuxMate Logo"
|
alt="TuxMate Logo"
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
import { useState } from 'react';
|
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 }) {
|
export function DistroIcon({ url, name, size = 20 }: { url: string; name: string; size?: number }) {
|
||||||
const [error, setError] = useState(false);
|
const [error, setError] = useState(false);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import { distros, type DistroId } from '@/lib/data';
|
|||||||
import { analytics } from '@/lib/analytics';
|
import { analytics } from '@/lib/analytics';
|
||||||
import { DistroIcon } from './DistroIcon';
|
import { DistroIcon } from './DistroIcon';
|
||||||
|
|
||||||
// Distro picker dropdown.
|
|
||||||
export function DistroSelector({
|
export function DistroSelector({
|
||||||
selectedDistro,
|
selectedDistro,
|
||||||
onSelect
|
onSelect
|
||||||
|
|||||||
@@ -419,7 +419,6 @@ export function Sidebar({
|
|||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<ThemeToggle />
|
<ThemeToggle />
|
||||||
|
|
||||||
{/* Links */}
|
|
||||||
<div className="flex items-center gap-0.5">
|
<div className="flex items-center gap-0.5">
|
||||||
<a
|
<a
|
||||||
href="https://github.com/abusoww/tuxmate"
|
href="https://github.com/abusoww/tuxmate"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// Umami Analytics Utility
|
|
||||||
// https://umami.is/docs/track-events
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
@@ -9,7 +8,6 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Safe wrapper - works even if Umami hasn't loaded yet
|
|
||||||
export function track(
|
export function track(
|
||||||
eventName: string,
|
eventName: string,
|
||||||
eventData?: Record<string, string | number | boolean>
|
eventData?: Record<string, string | number | boolean>
|
||||||
@@ -19,25 +17,18 @@ export function track(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event names for the Umami dashboard
|
|
||||||
|
|
||||||
export const EVENTS = {
|
export const EVENTS = {
|
||||||
// Distro Selection
|
|
||||||
DISTRO_SELECTED: 'Distro Selected',
|
DISTRO_SELECTED: 'Distro Selected',
|
||||||
|
|
||||||
// App Interactions
|
|
||||||
APP_SELECTED: 'App Selected',
|
APP_SELECTED: 'App Selected',
|
||||||
APP_DESELECTED: 'App Deselected',
|
APP_DESELECTED: 'App Deselected',
|
||||||
|
|
||||||
// Command Actions
|
|
||||||
COMMAND_COPIED: 'Command Copied',
|
COMMAND_COPIED: 'Command Copied',
|
||||||
SCRIPT_DOWNLOADED: 'Script Downloaded',
|
SCRIPT_DOWNLOADED: 'Script Downloaded',
|
||||||
|
|
||||||
// Navigation
|
|
||||||
GITHUB_CLICKED: 'GitHub Clicked',
|
GITHUB_CLICKED: 'GitHub Clicked',
|
||||||
CONTRIBUTE_CLICKED: 'Contribute Clicked',
|
CONTRIBUTE_CLICKED: 'Contribute Clicked',
|
||||||
|
|
||||||
// UI Interactions
|
|
||||||
HELP_OPENED: 'How It Works Opened',
|
HELP_OPENED: 'How It Works Opened',
|
||||||
HELP_CLOSED: 'How It Works Closed',
|
HELP_CLOSED: 'How It Works Closed',
|
||||||
THEME_CHANGED: 'Theme Changed',
|
THEME_CHANGED: 'Theme Changed',
|
||||||
@@ -45,8 +36,6 @@ export const EVENTS = {
|
|||||||
CATEGORY_COLLAPSED: 'Category Collapsed',
|
CATEGORY_COLLAPSED: 'Category Collapsed',
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// Helper functions so we don't have to remember event names
|
|
||||||
|
|
||||||
export const analytics = {
|
export const analytics = {
|
||||||
distroSelected: (distro: string) => {
|
distroSelected: (distro: string) => {
|
||||||
track(EVENTS.DISTRO_SELECTED, { distro });
|
track(EVENTS.DISTRO_SELECTED, { distro });
|
||||||
|
|||||||
@@ -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';
|
import aurPackages from './aur-packages.json';
|
||||||
|
|
||||||
// Suffixes that scream "I'm from the AUR"
|
|
||||||
export const AUR_PATTERNS = ['-bin', '-git', '-appimage'];
|
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);
|
export const KNOWN_AUR_PACKAGES = new Set(aurPackages.packages);
|
||||||
|
|
||||||
// Check if a package name is an AUR package
|
|
||||||
export function isAurPackage(packageName: string): boolean {
|
export function isAurPackage(packageName: string): boolean {
|
||||||
if (KNOWN_AUR_PACKAGES.has(packageName)) {
|
if (KNOWN_AUR_PACKAGES.has(packageName)) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -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 { distros, type DistroId } from './data';
|
||||||
import {
|
import {
|
||||||
getSelectedPackages,
|
getSelectedPackages,
|
||||||
@@ -15,14 +12,13 @@ import {
|
|||||||
generateHomebrewScript,
|
generateHomebrewScript,
|
||||||
} from './scripts';
|
} from './scripts';
|
||||||
|
|
||||||
interface ScriptOptions {
|
interface GenerateOptions {
|
||||||
distroId: DistroId;
|
distroId: DistroId;
|
||||||
selectedAppIds: Set<string>;
|
selectedAppIds: Set<string>;
|
||||||
helper?: 'yay' | 'paru';
|
helper?: 'yay' | 'paru';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Full install script for download. Nix gets a config file, others get shell scripts.
|
export function generateInstallScript(options: GenerateOptions): string {
|
||||||
export function generateInstallScript(options: ScriptOptions): string {
|
|
||||||
const { distroId, selectedAppIds, helper = 'yay' } = options;
|
const { distroId, selectedAppIds, helper = 'yay' } = options;
|
||||||
const distro = distros.find(d => d.id === distroId);
|
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 generateCommandline(options: GenerateOptions): string {
|
||||||
export function generateSimpleCommand(selectedAppIds: Set<string>, distroId: DistroId): string {
|
const { selectedAppIds, distroId } = options;
|
||||||
const packages = getSelectedPackages(selectedAppIds, distroId);
|
const packages = getSelectedPackages(selectedAppIds, distroId);
|
||||||
if (packages.length === 0) return '# No packages selected';
|
if (packages.length === 0) return '# No packages selected';
|
||||||
|
|
||||||
|
|||||||
@@ -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 {
|
export function isUnfreePackage(pkg: string): boolean {
|
||||||
const cleanPkg = pkg.trim().toLowerCase();
|
const cleanPkg = pkg.trim().toLowerCase();
|
||||||
|
|
||||||
// Direct match
|
if (UNFREE_PACKAGES.has(cleanPkg)) return true;
|
||||||
if (KNOWN_UNFREE_PACKAGES.has(cleanPkg)) return true;
|
|
||||||
|
|
||||||
// Nested packages like jetbrains.idea-ultimate
|
for (const unfreePkg of Array.from(UNFREE_PACKAGES)) {
|
||||||
// We iterate because the set is small (matches original logic)
|
if (cleanPkg.includes(unfreePkg)) return true;
|
||||||
for (const unfree of KNOWN_UNFREE_PACKAGES) {
|
|
||||||
if (cleanPkg.includes(unfree)) return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Re-exports all distro script generators
|
|
||||||
|
|
||||||
export { escapeShellString, getSelectedPackages, type PackageInfo } from './shared';
|
export { escapeShellString, getSelectedPackages, type PackageInfo } from './shared';
|
||||||
export { generateUbuntuScript } from './ubuntu';
|
export { generateUbuntuScript } from './ubuntu';
|
||||||
|
|||||||
Reference in New Issue
Block a user