diff --git a/skills/website-creator/scripts/create_astro_website.py b/skills/website-creator/scripts/create_astro_website.py index 014b9c0..8c008fe 100644 --- a/skills/website-creator/scripts/create_astro_website.py +++ b/skills/website-creator/scripts/create_astro_website.py @@ -28,8 +28,11 @@ import sys import argparse import shutil import subprocess +import json +import time from pathlib import Path from datetime import datetime +from urllib.parse import urlparse # ============================================================================ @@ -425,7 +428,269 @@ def save_analytics_config(output_path: str, config: dict): print(f" ✓ Analytics config saved to context/data-services.json") -# ... (rest of functions remain the same - create_project, sync_to_gitea, etc.) +# ============================================================================ +# PROJECT CREATION FUNCTIONS +# ============================================================================ + +def create_project(args, languages, default_locale, features): + """Create the Astro project structure with templates.""" + output_path = Path(args.output) + project_name = args.name.lower().replace(' ', '-') + site_url = f"https://{project_name}.moreminimore.com" + + # Get template directory + script_dir = Path(__file__).parent + template_dir = script_dir / 'templates' + + print("\n📁 Creating project structure...") + + # Create directories + dirs = [ + output_path / 'public' / 'images', + output_path / 'src' / 'components' / 'common', + output_path / 'src' / 'components' / 'consent', + output_path / 'src' / 'components' / 'ui', + output_path / 'src' / 'layouts', + output_path / 'src' / 'pages', + output_path / 'src' / 'pages' / default_locale, + output_path / 'src' / 'styles', + output_path / 'src' / 'content' / 'blog', + output_path / 'src' / 'lib', + output_path / 'db', + ] + + for d in dirs: + d.mkdir(parents=True, exist_ok=True) + + print(" ✓ Directory structure created") + + # Copy templates if they exist + if template_dir.exists(): + print(" 📦 Copying templates with IDs...") + + # Copy layouts + layout_src = template_dir / 'layouts' / 'BaseLayout.astro' + if layout_src.exists(): + content = layout_src.read_text(encoding='utf-8') + content = content.replace("const siteName = 'Website Name'", f"const siteName = '{args.name}'") + content = content.replace("const siteUrl = 'https://example.com'", f"const siteUrl = '{site_url}'") + (output_path / 'src' / 'layouts' / 'BaseLayout.astro').write_text(content, encoding='utf-8') + + # Copy Header + header_src = template_dir / 'components' / 'common' / 'Header.astro' + if header_src.exists(): + shutil.copy(header_src, output_path / 'src' / 'components' / 'common' / 'Header.astro') + + # Copy Footer + footer_src = template_dir / 'components' / 'common' / 'Footer.astro' + if footer_src.exists(): + shutil.copy(footer_src, output_path / 'src' / 'components' / 'common' / 'Footer.astro') + + # Copy page templates + page_src = template_dir / 'pages' / 'index.astro' + if page_src.exists(): + shutil.copy(page_src, output_path / 'src' / 'pages' / default_locale / 'index.astro') + + # Copy styles + style_src = template_dir / 'styles' / 'global.css' + if style_src.exists(): + shutil.copy(style_src, output_path / 'src' / 'styles' / 'global.css') + + print(" ✓ Templates copied") + + # Create astro.config.mjs + locales_str = ', '.join([f"'{lang}'" for lang in languages]) + astro_config = ASTRO_CONFIG_TEMPLATE.format( + site_url=site_url, + locales=locales_str, + default_locale=default_locale + ) + (output_path / 'astro.config.mjs').write_text(astro_config, encoding='utf-8') + print(" ✓ astro.config.mjs created") + + # Create package.json + package_json = PACKAGE_JSON_TEMPLATE.format(name=project_name) + (output_path / 'package.json').write_text(package_json, encoding='utf-8') + print(" ✓ package.json created") + + # Create tsconfig.json + tsconfig = """{ + "extends": "astro/tsconfigs/strict", + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@/*": ["src/*"] + } + } +} +""" + (output_path / 'tsconfig.json').write_text(tsconfig, encoding='utf-8') + + # Create env file + env_content = f"""# Website Configuration +SITE_NAME={args.name} +SITE_URL={site_url} + +# Umami Analytics (optional - get from Umami dashboard) +# UMAMI_WEBSITE_ID= +# UMAMI_URL= +""" + (output_path / '.env').write_text(env_content, encoding='utf-8') + print(" ✓ Configuration files created") + + # Create basic index page if no template + if not (output_path / 'src' / 'pages' / default_locale / 'index.astro').exists(): + index_content = f"""--- +import BaseLayout from '../layouts/BaseLayout.astro'; +import Header from '../components/common/Header.astro'; +import Footer from '../components/common/Footer.astro'; +--- + + +
+
+
+

Welcome to {args.name}

+

Your trusted partner

+
+
+