diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 351829c..97dcbf5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,22 +1,43 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/python { - "name": "Tailspin Toys Dev Container", - "image": "mcr.microsoft.com/devcontainers/universal:latest", - "postCreateCommand": "./scripts/setup-env.sh", - "customizations": { - "vscode": { - "extensions": [ - "ms-dotnettools.csharp", - "GitHub.copilot", - "GitHub.copilot-chat", - "ms-python.vscode-pylance", - "svelte.svelte-vscode", - "astro-build.astro-vscode" - ] - } - }, - "features": { - "ghcr.io/devcontainers/features/dotnet:2": { - "version": "9.0" - } - } + "name": "Python 3", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye", + "features": { + "ghcr.io/devcontainers/features/node:1": {}, + "ghcr.io/schlich/devcontainer-features/playwright:0": {}, + "ghcr.io/devcontainers-extra/features/typescript:2": {} + }, + "postCreateCommand": "./scripts/setup-env.sh", + "customizations": { + "vscode": { + "extensions": [ + "ms-dotnettools.csharp", + "GitHub.copilot", + "GitHub.copilot-chat", + "ms-python.vscode-pylance", + "svelte.svelte-vscode", + "astro-build.astro-vscode" + ] + } + }, + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [ + 4321, + 5100 + ], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "pip3 install --user -r requirements.txt", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" } diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fc96c08..87a9b96 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -21,3 +21,7 @@ updates: dependency-type: production update-types: - patch + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index c7aaf24..626628c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,8 +9,11 @@ "devcontainer", "devcontainers", "docstrings", + "dotnettools", "isouter", "prebuild", + "pylance", + "schlich", "SDLC" ], "github.copilot.nextEditSuggestions.enabled": true, diff --git a/client/package-lock.json b/client/package-lock.json index 4b80791..0f53874 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -2625,10 +2625,9 @@ } }, "node_modules/devalue": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.1.1.tgz", - "integrity": "sha512-maua5KUiapvEwiEAe+XnlZ3Rh0GD+qI1J/nb9vrJc3muPXvcF/8gXYTWF76+5DAqHyDUtOIImEuo0YKE9mshVw==", - "license": "MIT" + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.3.2.tgz", + "integrity": "sha512-UDsjUbpQn9kvm68slnrs+mfxwFkIflOhkanmyabZ8zOYk8SMEIbJ3TK+88g70hSIeytu4y18f0z/hYHMTrXIWw==" }, "node_modules/devlop": { "version": "1.1.0", @@ -5937,10 +5936,9 @@ } }, "node_modules/vite": { - "version": "6.3.5", - "resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz", - "integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==", - "license": "MIT", + "version": "6.3.6", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.3.6.tgz", + "integrity": "sha512-0msEVHJEScQbhkbVTb/4iHZdJ6SXp/AvxL2sjwYQFfBqleHtnCqv1J3sa9zbWz/6kW1m9Tfzn92vW+kZ1WV6QA==", "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.4.4", diff --git a/client/package.json b/client/package.json index 25a6163..b4e11da 100644 --- a/client/package.json +++ b/client/package.json @@ -7,7 +7,7 @@ "build": "astro build", "preview": "astro preview", "astro": "astro", - "test:e2e": "npx playwright test" + "test:e2e": "npx playwright install && npx playwright test" }, "dependencies": { "@astrojs/node": "^9.3.0", diff --git a/server/app.py b/server/app.py index 9ccc7bf..cc5c6f7 100644 --- a/server/app.py +++ b/server/app.py @@ -1,16 +1,22 @@ import os from flask import Flask -from models import init_db from routes.games import games_bp -from utils.database import init_db +from models import db +from utils.database import get_connection_string # Get the server directory path base_dir: str = os.path.abspath(os.path.dirname(__file__)) app: Flask = Flask(__name__) -# Initialize the database with the app -init_db(app) +# Configure and initialize the database +app.config['SQLALCHEMY_DATABASE_URI'] = get_connection_string() +app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False +db.init_app(app) + +# Create tables +with app.app_context(): + db.create_all() # Register blueprints app.register_blueprint(games_bp) diff --git a/server/models/__init__.py b/server/models/__init__.py index d80608b..b36d7a7 100644 --- a/server/models/__init__.py +++ b/server/models/__init__.py @@ -5,25 +5,4 @@ # Import models after db is defined to avoid circular imports from .category import Category from .game import Game -from .publisher import Publisher - -def init_db(app, testing: bool = False): - """Initialize the database - - Args: - app: The Flask application instance - testing: If True, allows reinitialization for testing - """ - if testing: - # For testing, we want to be able to reinitialize - db.init_app(app) - else: - try: - db.init_app(app) - except RuntimeError: - # Database already initialized - pass - - # Create tables when initializing - with app.app_context(): - db.create_all() \ No newline at end of file +from .publisher import Publisher \ No newline at end of file diff --git a/server/tests/test_games.py b/server/tests/test_games.py index 145608c..a70a64d 100644 --- a/server/tests/test_games.py +++ b/server/tests/test_games.py @@ -2,7 +2,7 @@ import json from typing import Dict, List, Any, Optional from flask import Flask, Response -from models import Game, Publisher, Category, db, init_db +from models import Game, Publisher, Category, db from routes.games import games_bp class TestGamesRoutes(unittest.TestCase): @@ -52,7 +52,7 @@ def setUp(self) -> None: self.client = self.app.test_client() # Initialize in-memory database for testing - init_db(self.app, testing=True) + db.init_app(self.app) # Create tables and seed data with self.app.app_context(): diff --git a/server/utils/database.py b/server/utils/database.py index ae46475..7111179 100644 --- a/server/utils/database.py +++ b/server/utils/database.py @@ -1,23 +1,6 @@ import os -from models import init_db as models_init_db -def init_db(app, connection_string=None, testing=False): - """ - Initializes the database with the given Flask app and connection string. - If no connection string is provided, a default SQLite connection string is used. - - Args: - app: The Flask application instance - connection_string: Optional database connection string - testing: If True, allows reinitialization for testing - """ - if connection_string is None: - connection_string = __get_connection_string() - app.config['SQLALCHEMY_DATABASE_URI'] = connection_string - app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False - models_init_db(app, testing=testing) - -def __get_connection_string(): +def get_connection_string() -> str: """ Returns the connection string for the database. """ diff --git a/server/utils/seed_database.py b/server/utils/seed_database.py index 7e26e94..ab054c8 100644 --- a/server/utils/seed_database.py +++ b/server/utils/seed_database.py @@ -3,14 +3,20 @@ import random from flask import Flask from models import db, Category, Game, Publisher -from utils.database import init_db +from utils.database import get_connection_string def create_app(): """Create and configure Flask app for database operations""" app = Flask(__name__) - # Initialize the database with the app - init_db(app) + # Configure and initialize the database + app.config['SQLALCHEMY_DATABASE_URI'] = get_connection_string() + app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False + db.init_app(app) + + # Create tables + with app.app_context(): + db.create_all() return app