everydaydevops-luff 3.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. everydaydevops_luff-3.0.0.data/data/share/luff/skills/flutter-audit/SKILL.md +30 -0
  2. everydaydevops_luff-3.0.0.data/data/share/luff/skills/flutter-create/SKILL.md +27 -0
  3. everydaydevops_luff-3.0.0.data/data/share/luff/skills/flutter-feature/SKILL.md +30 -0
  4. everydaydevops_luff-3.0.0.data/data/share/luff/skills/flutter-migrate/SKILL.md +30 -0
  5. everydaydevops_luff-3.0.0.data/data/share/luff/skills/flutter-verify/SKILL.md +12 -0
  6. everydaydevops_luff-3.0.0.dist-info/METADATA +50 -0
  7. everydaydevops_luff-3.0.0.dist-info/RECORD +40 -0
  8. everydaydevops_luff-3.0.0.dist-info/WHEEL +5 -0
  9. everydaydevops_luff-3.0.0.dist-info/entry_points.txt +3 -0
  10. everydaydevops_luff-3.0.0.dist-info/licenses/LICENSE +21 -0
  11. everydaydevops_luff-3.0.0.dist-info/top_level.txt +1 -0
  12. flutter_setup/__init__.py +0 -0
  13. flutter_setup/appender.py +46 -0
  14. flutter_setup/bootstrap.py +1655 -0
  15. flutter_setup/cicd_generator.py +885 -0
  16. flutter_setup/cli.py +1193 -0
  17. flutter_setup/config.py +156 -0
  18. flutter_setup/config_manager.py +160 -0
  19. flutter_setup/core.py +204 -0
  20. flutter_setup/exceptions.py +37 -0
  21. flutter_setup/flutter_manager.py +579 -0
  22. flutter_setup/platform.py +15 -0
  23. flutter_setup/prerequisites.py +39 -0
  24. flutter_setup/prerequisites_linux.py +140 -0
  25. flutter_setup/prerequisites_macos.py +226 -0
  26. flutter_setup/project_cli.py +397 -0
  27. flutter_setup/project_creator.py +91 -0
  28. flutter_setup/standards.py +99 -0
  29. flutter_setup/standards_data/everyday-devops-flutter-1.0.0.json +97 -0
  30. flutter_setup/standards_data/manifest-v1.schema.json +209 -0
  31. flutter_setup/templates/everyday/AGENTS.md +5 -0
  32. flutter_setup/templates/everyday/app_log.dart +6 -0
  33. flutter_setup/templates/everyday/home_content.dart +9 -0
  34. flutter_setup/templates/everyday/home_repository.dart +8 -0
  35. flutter_setup/templates/everyday/home_screen.dart +60 -0
  36. flutter_setup/templates/everyday/offline_store.dart +5 -0
  37. flutter_setup/templates/everyday/sentry_startup.dart +16 -0
  38. flutter_setup/templates/everyday/theme.dart +12 -0
  39. flutter_setup/templates.py +73 -0
  40. flutter_setup/verification.py +160 -0
@@ -0,0 +1,156 @@
1
+ """Configuration and data models for Flutter Setup."""
2
+
3
+ import os
4
+ import subprocess
5
+ from dataclasses import dataclass
6
+ from pathlib import Path
7
+ from typing import Any, List, Literal
8
+
9
+ # Type aliases
10
+ FlutterChannel = Literal["stable", "beta"]
11
+ TemplateType = Literal["app", "plugin"]
12
+ IosLanguage = Literal["swift", "objc"]
13
+ AndroidLanguage = Literal["kotlin", "java"]
14
+ UpdateMode = Literal["reset", "reclone", "skip"]
15
+ Platform = Literal["ios", "android", "macos", "linux", "windows", "web"]
16
+ Architecture = Literal["basic", "clean"]
17
+ Database = Literal["none", "sqlite"]
18
+ Testing = Literal["standard", "mocktail"]
19
+ E2ETesting = Literal["integration_test", "patrol"]
20
+ AuthProvider = Literal["none", "firebase"]
21
+ CloudDatabase = Literal["none", "firestore"]
22
+ NotificationsProvider = Literal["none", "firebase"]
23
+
24
+
25
+ @dataclass
26
+ class Config:
27
+ """Configuration for Flutter setup."""
28
+
29
+ project_name: str
30
+ platforms: List[str]
31
+ org: str
32
+ channel: FlutterChannel
33
+ output_dir: Path
34
+ template: TemplateType
35
+ ios_language: IosLanguage
36
+ android_language: AndroidLanguage
37
+ flutter_update_mode: UpdateMode
38
+ dry_run: bool
39
+ verbose: bool
40
+ flutter_location: Path
41
+ architecture: Architecture = "basic"
42
+ database: Database = "none"
43
+ testing: Testing = "standard"
44
+ e2e_testing: E2ETesting = "integration_test"
45
+ auth_provider: AuthProvider = "none"
46
+ cloud_database: CloudDatabase = "none"
47
+ notifications_provider: NotificationsProvider = "none"
48
+ flutter_version: str | None = None
49
+ managed: bool = False
50
+ offline: bool = False
51
+ sentry: bool = False
52
+
53
+ def sdk_subprocess_options(self) -> dict[str, Any]:
54
+ if not self.managed:
55
+ return {}
56
+ return {
57
+ "stdin": subprocess.DEVNULL,
58
+ "timeout": 900,
59
+ "env": {**os.environ, "CI": "true", "FLUTTER_SUPPRESS_ANALYTICS": "true"},
60
+ }
61
+
62
+ def __post_init__(self) -> None:
63
+ """Validate configuration after initialization."""
64
+ self._validate()
65
+
66
+ def _validate(self) -> None:
67
+ """Validate configuration values."""
68
+ if not self.project_name:
69
+ raise ValueError("Project name cannot be empty")
70
+
71
+ if not self.platforms:
72
+ raise ValueError("At least one platform must be specified")
73
+
74
+ # Basic normalization
75
+ self.platforms = [p.strip().lower() for p in self.platforms if p.strip()]
76
+
77
+ # Validate platforms
78
+ valid_platforms = {"ios", "android", "macos", "linux", "windows", "web"}
79
+ for platform in self.platforms:
80
+ if platform not in valid_platforms:
81
+ raise ValueError(f"Invalid platform: {platform}")
82
+
83
+ # Validate template-specific options
84
+ if self.template == "plugin":
85
+ if self.ios_language not in ["swift", "objc"]:
86
+ raise ValueError(f"Invalid iOS language: {self.ios_language}")
87
+ if self.android_language not in ["kotlin", "java"]:
88
+ raise ValueError(f"Invalid Android language: {self.android_language}")
89
+
90
+ if self.architecture not in ["basic", "clean"]:
91
+ raise ValueError(f"Invalid architecture: {self.architecture}")
92
+
93
+ if self.database not in ["none", "sqlite"]:
94
+ raise ValueError(f"Invalid database: {self.database}")
95
+
96
+ if self.testing not in ["standard", "mocktail"]:
97
+ raise ValueError(f"Invalid testing framework: {self.testing}")
98
+
99
+ if self.e2e_testing not in ["integration_test", "patrol"]:
100
+ raise ValueError(
101
+ f"Invalid end-to-end testing framework: {self.e2e_testing}"
102
+ )
103
+
104
+ if self.auth_provider not in ["none", "firebase"]:
105
+ raise ValueError(f"Invalid auth provider: {self.auth_provider}")
106
+
107
+ if self.cloud_database not in ["none", "firestore"]:
108
+ raise ValueError(f"Invalid cloud database: {self.cloud_database}")
109
+
110
+ if self.notifications_provider not in ["none", "firebase"]:
111
+ raise ValueError(
112
+ f"Invalid notifications provider: {self.notifications_provider}"
113
+ )
114
+
115
+ if self.flutter_version is not None:
116
+ import re
117
+
118
+ if not re.fullmatch(r"\d+\.\d+\.\d+", self.flutter_version):
119
+ raise ValueError(
120
+ f"Invalid flutter_version '{self.flutter_version}': must be X.Y.Z (e.g. 3.24.0)"
121
+ )
122
+
123
+ @property
124
+ def project_path(self) -> Path:
125
+ """Get the full project path."""
126
+ return self.output_dir / self.project_name
127
+
128
+ @property
129
+ def package_name(self) -> str:
130
+ """Get the sanitized package name."""
131
+ return self._sanitize_package_name(self.project_name)
132
+
133
+ @property
134
+ def platforms_csv(self) -> str:
135
+ """Get platforms as comma-separated string."""
136
+ return ",".join(self.platforms)
137
+
138
+ def _sanitize_package_name(self, name: str) -> str:
139
+ """Sanitize package name for Flutter."""
140
+ import re
141
+
142
+ # Convert to lowercase and replace non-alphanumeric with underscores
143
+ sanitized = re.sub(r"[^a-z0-9_]", "_", name.lower())
144
+
145
+ # Ensure it starts with a letter
146
+ if sanitized and not sanitized[0].isalpha():
147
+ sanitized = f"app_{sanitized}"
148
+
149
+ # Remove leading/trailing underscores
150
+ sanitized = sanitized.strip("_")
151
+
152
+ # Ensure it's not empty
153
+ if not sanitized:
154
+ sanitized = "app"
155
+
156
+ return sanitized
@@ -0,0 +1,160 @@
1
+ """Configuration file management with XDG Base Directory Specification support."""
2
+
3
+ import os
4
+ import shutil
5
+ from pathlib import Path
6
+ from typing import Any, Dict, Optional
7
+
8
+ import yaml
9
+ from rich.console import Console
10
+
11
+ console = Console()
12
+
13
+
14
+ class ConfigManager:
15
+ """Manages configuration file using XDG Base Directory Specification."""
16
+
17
+ def __init__(self) -> None:
18
+ """Initialize ConfigManager with XDG-compliant paths."""
19
+ self.config_dir = self._get_config_dir()
20
+ self.config_file = self.config_dir / "config.yaml"
21
+
22
+ def _get_config_dir(self) -> Path:
23
+ """Get config directory following XDG Base Directory Specification."""
24
+ # XDG_CONFIG_HOME takes precedence, fallback to ~/.config
25
+ xdg_config_home = os.getenv("XDG_CONFIG_HOME")
26
+ if xdg_config_home:
27
+ config_dir = Path(xdg_config_home) / "flutter-setup"
28
+ else:
29
+ config_dir = Path.home() / ".config" / "flutter-setup"
30
+
31
+ return config_dir
32
+
33
+ def ensure_config_dir(self) -> None:
34
+ """Ensure config directory exists, creating it if necessary."""
35
+ self.config_dir.mkdir(parents=True, exist_ok=True)
36
+
37
+ def get_default_config(self) -> Dict[str, Any]:
38
+ """Get default configuration values."""
39
+ home = Path.home()
40
+ default_flutter_location = str(home / "development" / "flutter")
41
+
42
+ return {
43
+ "flutter": {
44
+ "location": default_flutter_location,
45
+ "channel": "stable",
46
+ "update_mode": "skip",
47
+ },
48
+ "project": {
49
+ "org": "com.example",
50
+ "template": "app",
51
+ "architecture": "basic",
52
+ "database": "none",
53
+ "testing": "standard",
54
+ "e2e_testing": "integration_test",
55
+ "auth_provider": "none",
56
+ "cloud_database": "none",
57
+ "notifications_provider": "none",
58
+ "ios_language": "swift",
59
+ "android_language": "kotlin",
60
+ },
61
+ }
62
+
63
+ def create_default_config(self) -> None:
64
+ """Create default config file if it doesn't exist."""
65
+ if self.config_file.exists():
66
+ return
67
+
68
+ self.ensure_config_dir()
69
+
70
+ default_config = self.get_default_config()
71
+
72
+ try:
73
+ with open(self.config_file, "w") as f:
74
+ yaml.dump(default_config, f, default_flow_style=False, sort_keys=False)
75
+ console.print(
76
+ f"[dim]Created default config file at: {self.config_file}[/dim]"
77
+ )
78
+ except Exception as e:
79
+ console.print(
80
+ f"[yellow]Warning: Could not create config file: {e}[/yellow]"
81
+ )
82
+
83
+ def load_config(self) -> Dict[str, Any]:
84
+ """Load configuration from file, creating default if it doesn't exist."""
85
+ # Create default config if it doesn't exist
86
+ if not self.config_file.exists():
87
+ self.create_default_config()
88
+
89
+ if not self.config_file.exists():
90
+ # If we still can't create it, return defaults
91
+ return self.get_default_config()
92
+
93
+ try:
94
+ with open(self.config_file, "r") as f:
95
+ config = yaml.safe_load(f) or {}
96
+ return config
97
+ except Exception as e:
98
+ console.print(
99
+ f"[yellow]Warning: Could not load config file: {e}. Using defaults.[/yellow]"
100
+ )
101
+ return self.get_default_config()
102
+
103
+ def save_config(self, config: Dict[str, Any]) -> None:
104
+ """Save configuration to file."""
105
+ self.ensure_config_dir()
106
+
107
+ try:
108
+ with open(self.config_file, "w") as f:
109
+ yaml.dump(config, f, default_flow_style=False, sort_keys=False)
110
+ except Exception as e:
111
+ console.print(f"[yellow]Warning: Could not save config file: {e}[/yellow]")
112
+
113
+ def get_flutter_location(self) -> Optional[Path]:
114
+ """Get Flutter location from config file."""
115
+ config = self.load_config()
116
+ flutter_location = config.get("flutter", {}).get("location")
117
+ if flutter_location:
118
+ return Path(flutter_location)
119
+ return None
120
+
121
+ def set_flutter_location(self, location: Path) -> None:
122
+ """Set Flutter location in config file."""
123
+ config = self.load_config()
124
+ if "flutter" not in config:
125
+ config["flutter"] = {}
126
+ config["flutter"]["location"] = str(location)
127
+ self.save_config(config)
128
+
129
+ def detect_flutter_location(self) -> Optional[Path]:
130
+ """Detect Flutter location from environment variables or PATH."""
131
+ # Check FLUTTER_ROOT environment variable
132
+ flutter_root = os.getenv("FLUTTER_ROOT")
133
+ if flutter_root:
134
+ path = Path(flutter_root)
135
+ if path.exists() and (path / "bin" / "flutter").exists():
136
+ return path
137
+
138
+ # Check if flutter is in PATH
139
+ flutter_bin = shutil.which("flutter")
140
+ if flutter_bin:
141
+ # flutter_bin is something like /path/to/flutter/bin/flutter
142
+ flutter_path = Path(flutter_bin).parent.parent
143
+ if flutter_path.exists() and (flutter_path / ".git").exists():
144
+ return flutter_path
145
+
146
+ # Check common installation locations
147
+ home = Path.home()
148
+ common_paths = [
149
+ home / "development" / "flutter",
150
+ home / "flutter",
151
+ home / ".flutter",
152
+ Path("/usr/local/flutter"),
153
+ Path("/opt/flutter"),
154
+ ]
155
+
156
+ for path in common_paths:
157
+ if path.exists() and (path / "bin" / "flutter").exists():
158
+ return path
159
+
160
+ return None
flutter_setup/core.py ADDED
@@ -0,0 +1,204 @@
1
+ """Core Flutter setup functionality."""
2
+
3
+ from rich.console import Console
4
+ from rich.progress import Progress, SpinnerColumn, TextColumn
5
+ from rich.panel import Panel
6
+
7
+ from .config import Config
8
+ from .exceptions import (
9
+ FlutterSetupError,
10
+ PrerequisitesError,
11
+ FlutterInstallationError,
12
+ ProjectCreationError,
13
+ )
14
+ from .prerequisites import PrerequisitesManager
15
+ from .flutter_manager import FlutterManager
16
+ from .project_creator import ProjectCreator
17
+ from .bootstrap import ProjectBootstrap
18
+ from .platform import detect_runtime_platform
19
+
20
+ console = Console()
21
+
22
+
23
+ class FlutterSetup:
24
+ """Main class for orchestrating Flutter development environment setup."""
25
+
26
+ def __init__(self, config: Config):
27
+ """Initialize FlutterSetup with configuration."""
28
+ self.config = config
29
+ self.platform = detect_runtime_platform()
30
+ self.prerequisites = PrerequisitesManager(config)
31
+ self.flutter_manager = FlutterManager(config)
32
+ self.project_creator = ProjectCreator(config)
33
+ self.bootstrap = ProjectBootstrap(config)
34
+
35
+ def run(self) -> None:
36
+ """Run the complete Flutter setup process."""
37
+ console.print(
38
+ f"\n[bold blue]🚀 Starting Flutter setup for: {self.config.project_name}[/bold blue]"
39
+ )
40
+ console.print(
41
+ f"[dim]Template: {self.config.template} | Org: {self.config.org} | Channel: {self.config.channel}[/dim]"
42
+ )
43
+ console.print(
44
+ f"[dim]Architecture: {self.config.architecture} | Database: {self.config.database}[/dim]"
45
+ )
46
+ console.print(
47
+ f"[dim]Testing: {self.config.testing} | Auth: {self.config.auth_provider} | Cloud DB: {self.config.cloud_database} | Notifications: {self.config.notifications_provider}[/dim]"
48
+ )
49
+ console.print(
50
+ f"[dim]Platforms: {', '.join(self.config.platforms)} | Package: {self.config.package_name}[/dim]"
51
+ )
52
+ console.print(f"[dim]Host OS: {self.platform}[/dim]")
53
+ console.print(f"[dim]Output: {self.config.project_path}[/dim]")
54
+
55
+ if self.config.dry_run:
56
+ console.print(
57
+ "[yellow]⚠️ DRY RUN MODE - No actual changes will be made[/yellow]"
58
+ )
59
+
60
+ try:
61
+ # Step 1: Check and install prerequisites
62
+ self._run_prerequisites()
63
+
64
+ # Step 2: Install/update Flutter SDK
65
+ self._run_flutter_installation()
66
+
67
+ # Step 3: Create Flutter project
68
+ self._run_project_creation()
69
+
70
+ # Step 4: Bootstrap development environment
71
+ self._run_bootstrap()
72
+
73
+ # Step 5: Display next steps
74
+ self._show_next_steps()
75
+
76
+ except Exception as e:
77
+ console.print(f"\n[red]❌ Setup failed: {e}[/red]")
78
+ raise
79
+
80
+ def _run_prerequisites(self) -> None:
81
+ """Run prerequisites check and installation."""
82
+ console.print("\n[bold]📋 Checking prerequisites...[/bold]")
83
+
84
+ with Progress(
85
+ SpinnerColumn(),
86
+ TextColumn("[progress.description]{task.description}"),
87
+ console=console,
88
+ ) as progress:
89
+ task = progress.add_task("Checking system requirements...", total=None)
90
+
91
+ try:
92
+ self.prerequisites.check_and_install()
93
+ progress.update(task, description="✅ Prerequisites satisfied")
94
+ except Exception as e:
95
+ progress.update(task, description="❌ Prerequisites failed")
96
+ raise PrerequisitesError(f"Failed to install prerequisites: {e}")
97
+
98
+ def _run_flutter_installation(self) -> None:
99
+ """Run Flutter SDK installation/update."""
100
+ console.print("\n[bold]🦋 Installing/updating Flutter SDK...[/bold]")
101
+
102
+ with Progress(
103
+ SpinnerColumn(),
104
+ TextColumn("[progress.description]{task.description}"),
105
+ console=console,
106
+ ) as progress:
107
+ task = progress.add_task("Setting up Flutter SDK...", total=None)
108
+
109
+ try:
110
+ self.flutter_manager.ensure_flutter()
111
+ progress.update(task, description="✅ Flutter SDK ready")
112
+ except Exception as e:
113
+ progress.update(task, description="❌ Flutter installation failed")
114
+ raise FlutterInstallationError(f"Failed to install Flutter: {e}")
115
+
116
+ def _run_project_creation(self) -> None:
117
+ """Run Flutter project creation."""
118
+ console.print("\n[bold]🏗️ Creating Flutter project...[/bold]")
119
+
120
+ with Progress(
121
+ SpinnerColumn(),
122
+ TextColumn("[progress.description]{task.description}"),
123
+ console=console,
124
+ ) as progress:
125
+ task = progress.add_task("Creating project structure...", total=None)
126
+
127
+ try:
128
+ self.project_creator.create_project()
129
+ progress.update(task, description="✅ Project created")
130
+ except Exception as e:
131
+ progress.update(task, description="❌ Project creation failed")
132
+ raise ProjectCreationError(f"Failed to create project: {e}")
133
+
134
+ def _run_bootstrap(self) -> None:
135
+ """Run project bootstrapping."""
136
+ console.print("\n[bold]🔧 Bootstrapping development environment...[/bold]")
137
+
138
+ with Progress(
139
+ SpinnerColumn(),
140
+ TextColumn("[progress.description]{task.description}"),
141
+ console=console,
142
+ ) as progress:
143
+ task = progress.add_task("Setting up development tools...", total=None)
144
+
145
+ try:
146
+ self.bootstrap.bootstrap_project()
147
+ progress.update(task, description="✅ Development environment ready")
148
+ except Exception as e:
149
+ progress.update(task, description="❌ Bootstrap failed")
150
+ raise FlutterSetupError(f"Failed to bootstrap project: {e}")
151
+
152
+ def _show_next_steps(self) -> None:
153
+ """Display next steps for the user."""
154
+ console.print("\n[bold green]🎉 Setup completed successfully![/bold green]")
155
+
156
+ if self.platform == "darwin":
157
+ shell_profile_steps = (
158
+ " [code]source ~/.zprofile[/code] # zsh login shells\n"
159
+ " [code]source ~/.zshrc[/code] # zsh interactive shells"
160
+ )
161
+ else:
162
+ shell_profile_steps = (
163
+ " [code]source ~/.bashrc[/code] # bash\n"
164
+ " [code]source ~/.zshrc[/code] # zsh"
165
+ )
166
+ platform_run_labels = {
167
+ "web": ("make run-chrome", "runs on Chrome"),
168
+ "ios": ("make run-ios", "runs on iOS simulator"),
169
+ "android": ("make run-android", "runs on Android emulator"),
170
+ }
171
+ run_steps = "\n".join(
172
+ f" [code]{cmd}[/code] # {label}"
173
+ for p in self.config.platforms
174
+ if (entry := platform_run_labels.get(p))
175
+ for cmd, label in [entry]
176
+ )
177
+ if not run_steps:
178
+ run_steps = " [code]flutter run[/code]"
179
+
180
+ next_steps = f"""
181
+ [bold]Next steps:[/bold]
182
+
183
+ 1. [blue]Activate Flutter in your shell:[/blue]
184
+ {shell_profile_steps}
185
+
186
+ 2. [blue]Navigate to your project:[/blue]
187
+ [code]cd "{self.config.project_path}"[/code]
188
+
189
+ 3. [blue]Run your Flutter app:[/blue]
190
+ {run_steps}
191
+
192
+ 4. [blue]Test your setup:[/blue]
193
+ [code]make test[/code] # run unit + widget tests
194
+ [code]make analyze[/code] # check lints
195
+
196
+ 5. [blue]Open in Cursor/VS Code:[/blue]
197
+ Hit F5 ("Flutter Debug") to start debugging
198
+
199
+ [dim]Your project is located at: {self.config.project_path}[/dim]
200
+ """
201
+
202
+ console.print(
203
+ Panel(next_steps, title="🚀 Ready to Code!", border_style="green")
204
+ )
@@ -0,0 +1,37 @@
1
+ """Custom exceptions for Flutter Setup."""
2
+
3
+
4
+ class FlutterSetupError(Exception):
5
+ """Base exception for Flutter setup errors."""
6
+
7
+ pass
8
+
9
+
10
+ class PrerequisitesError(FlutterSetupError):
11
+ """Raised when prerequisites are not met."""
12
+
13
+ pass
14
+
15
+
16
+ class FlutterInstallationError(FlutterSetupError):
17
+ """Raised when Flutter installation fails."""
18
+
19
+ pass
20
+
21
+
22
+ class ProjectCreationError(FlutterSetupError):
23
+ """Raised when project creation fails."""
24
+
25
+ pass
26
+
27
+
28
+ class ConfigurationError(FlutterSetupError):
29
+ """Raised when configuration is invalid."""
30
+
31
+ pass
32
+
33
+
34
+ class SystemError(FlutterSetupError):
35
+ """Raised when system-level operations fail."""
36
+
37
+ pass