Consolidate feature flags to ALWRITY_ENABLED_FEATURES

Backend:
- Add get_enabled_features() returning set from ALWRITY_ENABLED_FEATURES
- Update router registry to use 'features' instead of 'profiles'
- Support feature names: podcast, blog-writer, youtube, story-writer, etc
- Update bootstrap gating to use enabled features
- Update PODCAST_ONLY_DEMO_MODE to check new flag first
- Add backwards compatibility with legacy env vars

Frontend:
- Update demoMode.ts to use REACT_APP_ENABLED_FEATURES
- Add getEnabledFeatures() and isFeatureEnabled() utilities

Usage:
  ALWRITY_ENABLED_FEATURES=all          # All features (default)
  ALWRITY_ENABLED_FEATURES=podcast      # Podcast only
  ALWRITY_ENABLED_FEATURES=podcast,core # Podcast + core features
This commit is contained in:
ajaysi
2026-03-31 18:40:54 +05:30
parent 9f0298725a
commit cd06c6aaa8
5 changed files with 240 additions and 112 deletions

View File

@@ -59,18 +59,47 @@ def _env_flag_enabled(*env_names: str) -> bool:
return False
PODCAST_ONLY_DEMO_MODE = _env_flag_enabled(
"ALWRITY_PODCAST_ONLY_DEMO_MODE",
"PODCAST_ONLY_DEMO_MODE",
)
def get_enabled_features() -> set:
"""Get enabled features from environment variable.
ALWRITY_ENABLED_FEATURES can be:
- "all" - enable all features (default)
- comma-separated list: "podcast,core"
- single feature: "podcast"
"""
env_value = os.getenv(
"ALWRITY_ENABLED_FEATURES",
os.getenv("ALWRITY_FEATURE_PROFILE", os.getenv("ALWRITY_ROUTER_PROFILE", "all"))
).strip().lower()
if not env_value or env_value == "all":
return {"all"}
return {f.strip() for f in env_value.split(",") if f.strip()}
def is_podcast_only_demo_mode() -> bool:
return PODCAST_ONLY_DEMO_MODE
"""Check if podcast-only mode is enabled via new or legacy flags."""
# First check the new consolidated flag
enabled = get_enabled_features()
if "podcast" in enabled and "all" not in enabled:
return True
# Fall back to legacy flags for backwards compatibility
return _env_flag_enabled(
"ALWRITY_PODCAST_ONLY_DEMO_MODE",
"PODCAST_ONLY_DEMO_MODE"
)
def should_include_non_podcast_features() -> bool:
return not is_podcast_only_demo_mode()
"""Check if non-podcast features should be included."""
enabled = get_enabled_features()
return "all" in enabled or "core" in enabled or "blog-writer" in enabled
# Legacy constant for backwards compatibility - prefer using get_enabled_features()
PODCAST_ONLY_DEMO_MODE = is_podcast_only_demo_mode()
# Set up clean logging for end users