From 548092311c809b1dc68c4d97bfc563fd0aaa14b8 Mon Sep 17 00:00:00 2001 From: Void Date: Sat, 3 Jan 2026 16:45:57 +0800 Subject: [PATCH] update main.py --- main.py | 72 ++++++++++++++++----------------------------------------- 1 file changed, 20 insertions(+), 52 deletions(-) diff --git a/main.py b/main.py index a070056..0ce9edb 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 """ macOS Setup Wizard - Automatisierte Installation und Konfiguration Erstellt Verzeichnisse und installiert Apps aus einer JSON-Repository-Liste @@ -12,6 +11,10 @@ import urllib.request from pathlib import Path from typing import List, Dict +class Url: + DIRECTORIES = "https://raw.githubusercontent.com/VoidEUW/mac/refs/heads/main/v1/directories.json" + APPS = "https://raw.githubusercontent.com/VoidEUW/mac/refs/heads/main/v1/apps.json" + class Colors: """ANSI Farbcodes für Terminal-Ausgabe""" HEADER = '\033[95m' @@ -25,14 +28,22 @@ class Colors: class MacSetupWizard: def __init__(self): - self.directories: List[str] = [ - '~/Development', - '~/Development/Projects', - '~/Development/Tools', - '~/Documents/Work' - ] + self.directories: List[str] = [] self.apps: List[Dict[str, str]] = [] self.selected_apps: List[str] = [] + self.get_directories() + + def get_directories(self) -> None: + """Lädt die Verzeichnisse aus der JSON-Datei""" + try: + print(f"\n{Colors.YELLOW}Lade Directories...{Colors.END}") + with urllib.request.urlopen(Url.DIRECTORIES) as response: + data = json.loads(response.read().decode()) + self.directories = data.get('directories', []) + print(f"{Colors.GREEN}✓ {len(self.directories)} Directories geladen{Colors.END}") + except Exception as e: + print(f"{Colors.RED}✗ Fehler beim Laden der Verzeichnisse: {e}{Colors.END}") + self.directories = [] def clear_screen(self): """Terminal-Bildschirm leeren""" @@ -116,8 +127,6 @@ class MacSetupWizard: self.print_header("macOS Setup Wizard") self.print_step(2, 4, "Apps-Liste laden") - default_url = "https://raw.githubusercontent.com/username/repo/main/apps.json" - print(f"{Colors.YELLOW}Beispiel JSON-Format:{Colors.END}") print(json.dumps({ "apps": [ @@ -132,7 +141,7 @@ class MacSetupWizard: }, indent=2)) print(f"\n{Colors.CYAN}Repository-URL:{Colors.END}") - repo_url = input(f"[{default_url}]: ").strip() or default_url + repo_url = input(f"[{Url.APPS}]: ").strip() or Url.APPS try: print(f"\n{Colors.YELLOW}Lade Apps-Liste...{Colors.END}") @@ -142,51 +151,10 @@ class MacSetupWizard: print(f"{Colors.GREEN}✓ {len(self.apps)} Apps geladen{Colors.END}") except Exception as e: print(f"{Colors.RED}✗ Fehler beim Laden: {e}{Colors.END}") - print(f"{Colors.YELLOW}Verwende Demo-Daten...{Colors.END}") - self.apps = self.get_demo_apps() + self.apps = [] input(f"\n{Colors.GREEN}Enter drücken um fortzufahren...{Colors.END}") - def get_demo_apps(self) -> List[Dict[str, str]]: - """Demo-Apps für Testzwecke""" - return [ - { - "id": "homebrew", - "name": "Homebrew", - "url": "https://brew.sh", - "type": "script", - "install_command": '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' - }, - { - "id": "vscode", - "name": "Visual Studio Code", - "url": "https://code.visualstudio.com", - "type": "brew", - "install_command": "brew install --cask visual-studio-code" - }, - { - "id": "git", - "name": "Git", - "url": "https://git-scm.com", - "type": "brew", - "install_command": "brew install git" - }, - { - "id": "docker", - "name": "Docker Desktop", - "url": "https://www.docker.com/products/docker-desktop", - "type": "brew", - "install_command": "brew install --cask docker" - }, - { - "id": "iterm2", - "name": "iTerm2", - "url": "https://iterm2.com", - "type": "brew", - "install_command": "brew install --cask iterm2" - } - ] - def step_select_apps(self): """Schritt 3: Apps zur Installation auswählen""" self.clear_screen()