From d4f3cf90eca367e285a38d9c1b3a7399818c91f1 Mon Sep 17 00:00:00 2001 From: Nose Date: Wed, 21 Jan 2026 23:15:32 -0800 Subject: [PATCH] ff --- scripts/bootstrap.ps1 | 47 +------------------------------------------ scripts/bootstrap.py | 24 +++++++++++----------- 2 files changed, 13 insertions(+), 58 deletions(-) diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index e5ff436..d4ffb33 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -584,49 +584,4 @@ if (Get-Command -Name python -ErrorAction SilentlyContinue) { } Write-Host 'Error: no suitable Python 3 interpreter found. Please install Python 3 or use the venv.' -ForegroundColor Red -exit 127 # Inject the actual repo path safely (escape embedded double-quotes if any) - $ps1Text = $ps1Text.Replace('__REPO__', $repo.Replace('"', '""')) - # Ensure the PowerShell shim falls back to the correct module when the venv isn't present - # (No legacy 'medeia_entry' shim - use the packaged entry 'scripts.cli_entry') - if (Test-Path $mmPs1) { - $bak = "$mmPs1.bak$(Get-Date -UFormat %s)" - Move-Item -Path $mmPs1 -Destination $bak -Force - } - Set-Content -LiteralPath $mmPs1 -Value $ps1Text -Encoding UTF8 - - # Ensure user's bin is on PATH (User env var) - try { - $cur = [Environment]::GetEnvironmentVariable('PATH', 'User') - if ($cur -notlike "*$globalBin*") { - if ($cur) { $new = ($globalBin + ';' + $cur) } else { $new = $globalBin } - [Environment]::SetEnvironmentVariable('PATH', $new, 'User') - # Update current session PATH for immediate use - $env:PATH = $globalBin + ';' + $env:PATH - Write-Log "Added $globalBin to User PATH. Restart your shell to pick this up." "INFO" - } else { - Write-Log "$globalBin is already on the User PATH" "INFO" - } - } catch { - Write-Log "Failed to update user PATH: $_" "ERROR" - } -} catch { - Write-Log "Failed to install global launcher: $_" "ERROR" -} - -Write-Log "Bootstrap complete." "INFO" -Write-Host "" -Write-Host "To activate the venv:" -if ($IsWindowsPlatform) { - Write-Host " PS> .\$VenvPath\Scripts\Activate.ps1" - Write-Host " CMD> .\$VenvPath\Scripts\activate.bat" -} else { - Write-Host " $ source ./$VenvPath/bin/activate" -} -Write-Host "" -Write-Host "To run the app:" -Write-Host " $ .\$VenvPath\Scripts\mm.exe (Windows) or" -Write-Host " $ ./$VenvPath/bin/mm (Linux) or" -Write-Host " $ $venvPython -m scripts.cli_entry" -Write-Host "" -Write-Host "If the global 'mm' launcher fails, collect runtime diagnostics by setting MM_DEBUG and re-running the command:" -if ($IsWindowsPlatform) { Write-Host " PowerShell: $env:MM_DEBUG = '1'; mm" } else { Write-Host " POSIX: MM_DEBUG=1 mm" } +exit 127 diff --git a/scripts/bootstrap.py b/scripts/bootstrap.py index 480c90f..744c735 100644 --- a/scripts/bootstrap.py +++ b/scripts/bootstrap.py @@ -391,6 +391,9 @@ def _install_deno(version: str | None = None) -> int: def main() -> int: + # Ensure interactive stdin if piped + _ensure_interactive_stdin() + parser = argparse.ArgumentParser( description="Bootstrap Medios-Macina: install deps and Playwright browsers" ) @@ -488,11 +491,6 @@ def main() -> int: ) args = parser.parse_args() - # If stdout is a TTY but stdin is a pipe (e.g. curl | python), - # re-open stdin to the console so interactive prompts work. - if sys.stdout.isatty() and not args.quiet: - _ensure_interactive_stdin() - # Ensure repo_root is always the project root, not the current working directory # This prevents issues when bootstrap.py is run from different directories try: @@ -924,30 +922,32 @@ def main() -> int: print("✅ Installation check complete!") return 0 - # If no specific action flag is passed and we're in a terminal, show the menu - if (sys.stdin.isatty() or sys.stdout.isatty()) and not args.quiet: + # If no specific action flag is passed and we're in a terminal (or we're being piped), show the menu + if (sys.stdin.isatty() or sys.stdout.isatty() or script_path is None) and not args.quiet: sel = _interactive_menu() if sel == "install": # If running via pipe/standalone or not in a repo, ask for installation path - if not is_in_repo or script_path is None: + if script_path is None or not is_in_repo: if not shutil.which("git"): print("\nError: 'git' was not found on your PATH.", file=sys.stderr) print("Please install Git (https://git-scm.com/) and try again.", file=sys.stderr) return 1 try: + # Force a prompt to choose the folder if is_in_repo: default_install = repo_root else: default_install = Path.cwd() / "Medios-Macina" - print(f"\nWhere would you like to install Medeos-Macina?") + print(f"\n[WEB INSTALLER MODE]") + print(f"Where would you like to install Medios-Macina?") install_dir_raw = input(f"Installation directory [{default_install}]: ").strip() if not install_dir_raw: install_path = default_install else: install_path = Path(install_dir_raw).resolve() - except EOFError: + except (EOFError, KeyboardInterrupt): return 1 if not install_path.exists(): @@ -960,7 +960,7 @@ def main() -> int: print(f"Using existing repository in {install_path}.") repo_root = install_path else: - print(f"Cloning Medeos-Macina into {install_path} (depth 1)...") + print(f"Cloning Medios-Macina into {install_path} (depth 1)...") print(f"Source: {REPO_URL}") try: subprocess.check_call(["git", "clone", "--depth", "1", REPO_URL, str(install_path)]) @@ -1008,7 +1008,7 @@ def main() -> int: return 0 elif sel == 0: return 0 - elif not args.no_delegate: + elif not args.no_delegate and script_path is not None: # Default non-interactive behavior: delegate to platform script rc = run_platform_bootstrap(repo_root) if rc != 0: