Consolidate on ALWRITY_ENABLED_FEATURES - remove all legacy support
Backend: - Remove all legacy env var fallbacks (ALWRITY_FEATURE_PROFILE, ALWRITY_ROUTER_PROFILE, etc) - Remove get_active_profile() from start_alwrity_backend.py - Remove _env_flag_enabled() from app.py - Use ALWRITY_ENABLED_FEATURES as single source of truth Frontend: - demoMode.ts now uses only REACT_APP_ENABLED_FEATURES - Removed all legacy fallback keys (app_mode, demo_mode, podcast_only_demo_mode) Usage: ALWRITY_ENABLED_FEATURES=podcast # Podcast only ALWRITY_ENABLED_FEATURES=all # All features (default)
This commit is contained in:
@@ -1,55 +1,36 @@
|
||||
/**
|
||||
* Consolidated feature mode detection utilities.
|
||||
*
|
||||
* Primary: REACT_APP_ENABLED_FEATURES (format: "all" or "podcast,core")
|
||||
*
|
||||
* DEPRECATED (fallback order):
|
||||
* - REACT_APP_APP_MODE
|
||||
* - REACT_APP_DEMO_MODE
|
||||
* - REACT_APP_PODCAST_ONLY_DEMO_MODE
|
||||
* Primary env var: REACT_APP_ENABLED_FEATURES
|
||||
* Format: "all" or comma-separated: "podcast,core"
|
||||
*/
|
||||
|
||||
const ENABLED_FEATURES_STORAGE_KEYS = [
|
||||
'enabled_features', // Primary
|
||||
'app_mode',
|
||||
'demo_mode',
|
||||
'podcast_only_demo_mode',
|
||||
];
|
||||
|
||||
const ENABLED_FEATURES_ENV_KEYS = [
|
||||
'REACT_APP_ENABLED_FEATURES', // Primary - use this!
|
||||
'REACT_APP_APP_MODE', // DEPRECATED
|
||||
'REACT_APP_DEMO_MODE', // DEPRECATED
|
||||
'REACT_APP_PODCAST_ONLY_DEMO_MODE', // DEPRECATED
|
||||
];
|
||||
const PRIMARY_STORAGE_KEY = 'enabled_features';
|
||||
const PRIMARY_ENV_KEY = 'REACT_APP_ENABLED_FEATURES';
|
||||
|
||||
/**
|
||||
* Get enabled features from localStorage or environment.
|
||||
* Returns a set of enabled feature names.
|
||||
* Returns a Set of enabled feature names.
|
||||
*/
|
||||
export function getEnabledFeatures(): Set<string> {
|
||||
// Check localStorage first
|
||||
for (const key of ENABLED_FEATURES_STORAGE_KEYS) {
|
||||
const value = localStorage.getItem(key);
|
||||
if (value) {
|
||||
const features = value.toLowerCase().split(',').map(f => f.trim());
|
||||
if (features.includes('all')) {
|
||||
return new Set(['all']);
|
||||
}
|
||||
return new Set(features.filter(f => f));
|
||||
const storageValue = localStorage.getItem(PRIMARY_STORAGE_KEY);
|
||||
if (storageValue) {
|
||||
const features = storageValue.toLowerCase().split(',').map(f => f.trim());
|
||||
if (features.includes('all')) {
|
||||
return new Set(['all']);
|
||||
}
|
||||
return new Set(features.filter(f => f));
|
||||
}
|
||||
|
||||
// Check environment variables
|
||||
for (const key of ENABLED_FEATURES_ENV_KEYS) {
|
||||
const value = process.env[key];
|
||||
if (value) {
|
||||
const features = value.toLowerCase().split(',').map(f => f.trim());
|
||||
if (features.includes('all')) {
|
||||
return new Set(['all']);
|
||||
}
|
||||
return new Set(features.filter(f => f));
|
||||
// Check environment variable
|
||||
const envValue = process.env[PRIMARY_ENV_KEY];
|
||||
if (envValue) {
|
||||
const features = envValue.toLowerCase().split(',').map(f => f.trim());
|
||||
if (features.includes('all')) {
|
||||
return new Set(['all']);
|
||||
}
|
||||
return new Set(features.filter(f => f));
|
||||
}
|
||||
|
||||
// Default: all features enabled
|
||||
@@ -74,8 +55,8 @@ export function isPodcastOnlyDemoMode(): boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the app should skip onboarding entirely.
|
||||
* Returns true in podcast-only demo mode or when not using all features.
|
||||
* Check if the app should skip onboarding.
|
||||
* Returns true in podcast-only mode.
|
||||
*/
|
||||
export function shouldSkipOnboarding(): boolean {
|
||||
const enabled = getEnabledFeatures();
|
||||
|
||||
Reference in New Issue
Block a user