Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions run.bat

This file was deleted.

18 changes: 0 additions & 18 deletions run.sh

This file was deleted.

55 changes: 28 additions & 27 deletions make_release.py → scripts/make_release.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# make_release.py
# ShowTrackr Release Builder
# This script is used to create a release package for the ShowTrackr project.
# It copies specified files and folders from the project directory to a new release folder,
# scripts/make_release.py
# ShowTrackr-Web Release Builder
# This script is used to create a release package for the ShowTrackr-Web project.
# It copies specified files and folders from the project directory to a new release folder
# and optionally creates a zip archive of the release folder.
import shutil
import json
Expand All @@ -24,27 +24,26 @@
# --- CONFIGURABLE ---
# Files/folders to include (relative to project root)
INCLUDE = [
"apps/desktop/src/core",
"apps/desktop/data/.env.example",
"docs",
"src",
"scripts",
".gitignore",
"LICENSE",
"package.json",
"pyproject.toml",
"README.md",
"requirements.txt",
"run.bat",
"run.py",
"run.sh",
"setup.bat",
"setup.py",
"setup.sh",
]
# Files/folders to exclude (relative to project root, supports glob patterns)
EXCLUDE = [
"src/**/__pycache__",
"src/**/__pycache__/*",
"apps/**/__pycache__",
"apps/**/__pycache__/*",
"docs/previews",
"docs/previews/*",
"scripts/make_release.py",
"scripts/.coverage"
]

PROJECT_ROOT = Path(__file__).parent.resolve()
PROJECT_ROOT = Path(__file__).resolve().parent.parent


def get_version():
Expand Down Expand Up @@ -99,20 +98,22 @@ def copy_files_to_target_with_progress(target_dir):
total_files += count_files_to_copy(src_path, should_exclude)

with Progress(
TextColumn("[progress.description]{task.description}"),
BarColumn(),
"[progress.percentage]{task.percentage:>3.0f}%",
"{task.completed}/{task.total} files",
TimeElapsedColumn(),
console=console,
TextColumn("[progress.description]{task.description}"),
BarColumn(),
"[progress.percentage]{task.percentage:>3.0f}%",
"{task.completed}/{task.total} files",
TimeElapsedColumn(),
console=console,
) as progress:
task = progress.add_task("Copying files", total=total_files)
for item_name in INCLUDE:
src_path = PROJECT_ROOT / item_name
if src_path.exists():
try:
# Preserve the full relative path from the project root in the release
rel_path = Path(item_name)
copy_with_filter(
src_path, target_dir / src_path.name, progress, task
src_path, target_dir / rel_path, progress, task
)
except Exception as e:
console.print(f" [yellow]⚠️ Error copying {item_name}: {e}[/]")
Expand Down Expand Up @@ -218,7 +219,7 @@ def update_for_production_in_release(release_root, version, changes_list):
changes_list.append(("package.json", f"[ERROR] Could not update: {e}"))

# 2. config.py
config_path = Path(release_root) / "src" / "watchlist" / "config.py"
config_path = Path(release_root) / "apps" / "desktop" / "src" / "core" / "config.py"
try:
if config_path.exists():
with open(config_path, encoding="utf-8") as f:
Expand Down Expand Up @@ -275,7 +276,7 @@ def create_zip_archive(zip_path, root_dir_for_archive, base_dir_to_archive):


def handle_zip_only_release(
release_name_base, version_str, prod_mode_flag, changes_list_ref
release_name_base, version_str, prod_mode_flag, changes_list_ref
):
"""Handles the 'zip only' release process."""
zip_name = f"{release_name_base}.zip"
Expand All @@ -298,7 +299,7 @@ def handle_zip_only_release(


def handle_folder_release(
release_name_base, version_str, prod_mode_flag, changes_list_ref
release_name_base, version_str, prod_mode_flag, changes_list_ref
):
"""Handles the 'folder' release process."""
release_folder_path = PROJECT_ROOT / release_name_base
Expand Down Expand Up @@ -364,7 +365,7 @@ def main():
console.print(
"\n[bold cyan]==============================[/]", justify="center"
)
console.print("[bold magenta]ShowTrackr Release Builder[/]", justify="center")
console.print("[bold magenta]ShowTrackr-Web Release Builder[/]", justify="center")
console.print(
"[bold cyan]==============================\n[/]", justify="center"
)
Expand Down
29 changes: 29 additions & 0 deletions scripts/run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@echo off
setlocal
REM Run from anywhere - resolve project root relative to this script's location
cd /d "%~dp0.."

echo.
echo --- ShowTrackr-Web Launcher (Windows) ---
echo.

REM Use the venv Python directly - no manual activation needed
set VENV_PYTHON=.venv\Scripts\python.exe

if not exist "%VENV_PYTHON%" (
echo ERROR: Virtual environment not found.
echo Please run scripts\setup.bat first to set up the project.
echo.
pause
exit /b 1
)

set FLASK_APP=apps/desktop/src/core

echo Starting ShowTrackr-Web...
"%VENV_PYTHON%" scripts\run.py

echo.
echo Application stopped.
pause
endlocal
41 changes: 22 additions & 19 deletions run.py → scripts/run.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# run.py
# scripts/run.py
import os
import subprocess
import sys
from pathlib import Path
import platform

# Ensure the script is running from the project root directory
project_root = Path(__file__).parent.resolve()
# Locate project root (ShowTrackr-Web/) - this script lives in scripts/
project_root = Path(__file__).resolve().parent.parent
os.chdir(project_root)

# --- Virtual Environment Check ---
Expand All @@ -28,7 +28,6 @@
# Handle potential errors during path resolution if venv doesn't exist fully
current_executable = Path(sys.executable)


try:
from rich.console import Console
from rich.progress import (
Expand Down Expand Up @@ -58,10 +57,10 @@
console.print("\n[bold]Please activate the environment first:[/]")
if is_windows:
console.print("[green]> .\\.venv\\Scripts\\activate[/]")
console.print("Or run setup.bat / run.bat")
console.print("Or run scripts\\setup.bat / scripts\\run.bat")
else:
console.print("[green]$ source ./.venv/bin/activate[/]")
console.print("Or run setup.sh / run.sh")
console.print("Or run scripts/setup.sh / scripts/run.sh")
console.print(
"[yellow]Continuing, but dependency issues or unexpected behavior may occur.[/yellow]"
)
Expand All @@ -75,23 +74,25 @@
print("\nPlease activate the environment first:")
if is_windows:
print("> .\\.venv\\Scripts\\activate")
print("Or run setup.bat / run.bat")
print("Or run scripts\\setup.bat / scripts\\run.bat")
else:
print("$ source ./.venv/bin/activate")
print("Or run setup.sh / run.sh")
print("Or run scripts/setup.sh / scripts/run.sh")
print("------------")
print("Continuing, but dependency issues or unexpected behavior may occur.")
print("------------")

# --- Database Migration Progress ---
if os.environ.get("WERKZEUG_RUN_MAIN") != "true":
flask_env = os.environ.copy()
flask_env["FLASK_APP"] = "apps/desktop/src/core"
if console:
with Progress(
SpinnerColumn(),
TextColumn("[progress.description]{task.description}"),
BarColumn(),
TimeElapsedColumn(),
console=console,
SpinnerColumn(),
TextColumn("[progress.description]{task.description}"),
BarColumn(),
TimeElapsedColumn(),
console=console,
) as progress:
task = progress.add_task(
"Ensuring database migrations are up-to-date...", total=None
Expand All @@ -102,6 +103,7 @@
check=True,
cwd=project_root,
capture_output=True,
env=flask_env,
)
progress.update(
task,
Expand Down Expand Up @@ -133,6 +135,7 @@
check=True,
cwd=project_root,
capture_output=True,
env=flask_env,
)
print("Database migrations checked/applied successfully.")
except subprocess.CalledProcessError as e:
Expand All @@ -152,9 +155,9 @@

# --- Start Development Server ---
try:
src_path = project_root / "src"
src_path = project_root / "apps" / "desktop" / "src"
sys.path.insert(0, str(src_path))
from watchlist import create_app
from core import create_app

app = create_app()
if os.environ.get("WERKZEUG_RUN_MAIN") != "true":
Expand All @@ -172,16 +175,16 @@
if console:
console.print(f"[bold red]Error importing application:[/] {e}")
console.print(
"[yellow]Ensure all dependencies are installed (`pip install -r requirements.txt`)"
"[yellow]Ensure all dependencies are installed: run [bold]uv sync[/] from the project root."
)
console.print("Try running the setup script (setup.bat or setup.sh).")
console.print("Or run scripts/setup.bat (Windows) or scripts/setup.sh (Linux/macOS).")
else:
print(f"Error importing application: {e}", file=sys.stderr)
print(
"Ensure all dependencies are installed (`pip install -r requirements.txt`)",
"Ensure all dependencies are installed: run `uv sync` from the project root.",
file=sys.stderr,
)
print("Try running the setup script (setup.bat or setup.sh).", file=sys.stderr)
print("Or run scripts/setup.bat (Windows) or scripts/setup.sh (Linux/macOS).", file=sys.stderr)
sys.exit(1)
except KeyboardInterrupt:
if console:
Expand Down
29 changes: 29 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# Run from anywhere — resolve project root relative to this script's location
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$PROJECT_ROOT"

echo ""
echo "--- ShowTrackr-Web Launcher (Linux/macOS) ---"
echo ""

VENV_PYTHON=".venv/bin/python"

if [ ! -f "$VENV_PYTHON" ]; then
echo "ERROR: Virtual environment not found." >&2
echo "Please run scripts/setup.sh first to set up the project." >&2
echo ""
read -p "Press Enter to exit..."
exit 1
fi

export FLASK_APP="apps/desktop/src/core"

echo "Starting ShowTrackr-Web..."
"$VENV_PYTHON" scripts/run.py

echo ""
echo "Application stopped."
read -p "Press Enter to close terminal..."
exit 0
Loading
Loading