mirror of
https://github.com/abusoww/tuxmate.git
synced 2026-04-17 19:53:11 +02:00
refactor: extract AUR/Nix data to json
This commit is contained in:
@@ -105,7 +105,6 @@ export function CommandFooter({
|
||||
helper: selectedHelper,
|
||||
});
|
||||
const isNix = selectedDistro === 'nix';
|
||||
const ext = isNix ? 'nix' : 'sh';
|
||||
const mimeType = isNix ? 'text/plain' : 'text/x-shellscript';
|
||||
const blob = new Blob([script], { type: mimeType });
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
36
src/lib/aur-packages.json
Normal file
36
src/lib/aur-packages.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"packages": [
|
||||
"google-chrome",
|
||||
"zen-browser-bin",
|
||||
"helium-browser-bin",
|
||||
"slack-desktop",
|
||||
"zoom",
|
||||
"vesktop-bin",
|
||||
"sublime-text-4",
|
||||
"vscodium-bin",
|
||||
"cursor-bin",
|
||||
"vagrant",
|
||||
"postman-bin",
|
||||
"bruno-bin",
|
||||
"hoppscotch-bin",
|
||||
"spotify",
|
||||
"stremio",
|
||||
"heroic-games-launcher-bin",
|
||||
"protonup-qt-bin",
|
||||
"onlyoffice-bin",
|
||||
"logseq-desktop-bin",
|
||||
"joplin-appimage",
|
||||
"proton-vpn-gtk-app",
|
||||
"mullvad-vpn-bin",
|
||||
"localsend-bin",
|
||||
"dropbox",
|
||||
"ab-download-manager-bin",
|
||||
"bitwarden",
|
||||
"cura",
|
||||
"orcaslicer-bin",
|
||||
"davinci-resolve",
|
||||
"fsearch",
|
||||
"brave-bin",
|
||||
"librewolf-bin"
|
||||
]
|
||||
}
|
||||
@@ -1,86 +1,20 @@
|
||||
/**
|
||||
* AUR package detection for Arch users.
|
||||
* Figures out if a package comes from AUR or official repos.
|
||||
* Necessary because yay/paru handle AUR packages differently.
|
||||
*/
|
||||
// AUR package detection for Arch users
|
||||
// Identifies packages that come from the AUR vs official repos
|
||||
|
||||
/** Suffixes that scream "I'm from the AUR" */
|
||||
import aurPackages from './aur-packages.json';
|
||||
|
||||
// Suffixes that scream "I'm from the AUR"
|
||||
export const AUR_PATTERNS = ['-bin', '-git', '-appimage'];
|
||||
|
||||
/**
|
||||
* Known AUR packages that don't follow the suffix naming convention.
|
||||
* These are packages that exist only in AUR, not in official Arch repos.
|
||||
*/
|
||||
export const KNOWN_AUR_PACKAGES = new Set([
|
||||
// Browsers
|
||||
'google-chrome',
|
||||
'zen-browser-bin',
|
||||
'helium-browser-bin',
|
||||
// Known AUR packages without standard suffixes
|
||||
// Extracted to JSON for cleaner code
|
||||
export const KNOWN_AUR_PACKAGES = new Set(aurPackages.packages);
|
||||
|
||||
// Communication
|
||||
'slack-desktop',
|
||||
'zoom',
|
||||
'vesktop-bin',
|
||||
|
||||
// Dev Editors
|
||||
'sublime-text-4',
|
||||
'vscodium-bin',
|
||||
'cursor-bin',
|
||||
|
||||
// Dev Tools
|
||||
'vagrant',
|
||||
'postman-bin',
|
||||
'bruno-bin',
|
||||
'hoppscotch-bin',
|
||||
|
||||
// Dev Languages
|
||||
|
||||
// Media
|
||||
'spotify',
|
||||
'stremio',
|
||||
|
||||
// Gaming
|
||||
'heroic-games-launcher-bin',
|
||||
'protonup-qt-bin',
|
||||
|
||||
// Office
|
||||
'onlyoffice-bin',
|
||||
'logseq-desktop-bin',
|
||||
'joplin-appimage',
|
||||
|
||||
// VPN
|
||||
'proton-vpn-gtk-app',
|
||||
'mullvad-vpn-bin',
|
||||
|
||||
// File Sharing
|
||||
'localsend-bin',
|
||||
'dropbox',
|
||||
'ab-download-manager-bin',
|
||||
|
||||
// Security
|
||||
'bitwarden',
|
||||
|
||||
// Creative
|
||||
'cura',
|
||||
'orcaslicer-bin',
|
||||
'davinci-resolve',
|
||||
|
||||
// System
|
||||
'fsearch',
|
||||
|
||||
// Browsers (additional)
|
||||
'brave-bin',
|
||||
'librewolf-bin',
|
||||
]);
|
||||
|
||||
/**
|
||||
* Check if a package name is an AUR package
|
||||
* @param packageName - The Arch package name to check
|
||||
* @returns true if the package is from AUR
|
||||
*/
|
||||
// Check if a package name is an AUR package
|
||||
export function isAurPackage(packageName: string): boolean {
|
||||
if (KNOWN_AUR_PACKAGES.has(packageName)) {
|
||||
return true;
|
||||
}
|
||||
return AUR_PATTERNS.some(pattern => packageName.endsWith(pattern));
|
||||
}
|
||||
|
||||
|
||||
27
src/lib/nix-unfree.json
Normal file
27
src/lib/nix-unfree.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"packages": [
|
||||
"discord",
|
||||
"slack",
|
||||
"zoom-us",
|
||||
"teams",
|
||||
"skypeforlinux",
|
||||
"google-chrome",
|
||||
"vivaldi",
|
||||
"opera",
|
||||
"spotify",
|
||||
"steam",
|
||||
"vscode",
|
||||
"sublime",
|
||||
"sublime4",
|
||||
"jetbrains",
|
||||
"nvidia-x11",
|
||||
"dropbox",
|
||||
"1password",
|
||||
"masterpdfeditor",
|
||||
"postman",
|
||||
"obsidian",
|
||||
"davinci-resolve",
|
||||
"code-cursor",
|
||||
"vagrant"
|
||||
]
|
||||
}
|
||||
@@ -1,38 +1,22 @@
|
||||
// Nix unfree package detection - these require allowUnfree = true
|
||||
|
||||
export const KNOWN_UNFREE_PACKAGES = new Set([
|
||||
'discord',
|
||||
'slack',
|
||||
'zoom-us',
|
||||
'teams',
|
||||
'skypeforlinux',
|
||||
'google-chrome',
|
||||
'vivaldi',
|
||||
'opera',
|
||||
'spotify',
|
||||
'steam',
|
||||
'vscode',
|
||||
'sublime',
|
||||
'sublime4',
|
||||
'jetbrains',
|
||||
'nvidia-x11',
|
||||
'dropbox',
|
||||
'1password',
|
||||
'masterpdfeditor',
|
||||
'postman',
|
||||
'obsidian',
|
||||
'davinci-resolve',
|
||||
'code-cursor',
|
||||
'vagrant',
|
||||
]);
|
||||
import unfreeData from './nix-unfree.json';
|
||||
|
||||
// Loaded from JSON source
|
||||
export const KNOWN_UNFREE_PACKAGES = new Set(unfreeData.packages);
|
||||
|
||||
export function isUnfreePackage(pkg: string): boolean {
|
||||
const cleanPkg = pkg.trim().toLowerCase();
|
||||
|
||||
// Direct match
|
||||
if (KNOWN_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;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user