diff --git a/reflex/reflex.py b/reflex/reflex.py index 1426d33a6..38dc4c865 100644 --- a/reflex/reflex.py +++ b/reflex/reflex.py @@ -84,6 +84,10 @@ def _init( prerequisites.ensure_reflex_installation_id() + # When upgrading to 0.4, show migration instructions. + if prerequisites.should_show_rx_chakra_migration_instructions(): + prerequisites.show_rx_chakra_migration_instructions() + # Set up the app directory, only if the config doesn't exist. if not os.path.exists(constants.Config.FILE): if template is None: @@ -100,9 +104,6 @@ def _init( # Migrate Pynecone projects to Reflex. prerequisites.migrate_to_reflex() - if prerequisites.should_show_rx_chakra_migration_instructions(): - prerequisites.show_rx_chakra_migration_instructions() - # Initialize the .gitignore. prerequisites.initialize_gitignore() diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index 25119458e..48d587b7c 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -949,8 +949,15 @@ def should_show_rx_chakra_migration_instructions() -> bool: if os.getenv("REFLEX_PROMPT_MIGRATE_TO_RX_CHAKRA") == "yes": return True - with open(constants.Dirs.REFLEX_JSON, "r") as f: - data = json.load(f) + if not Path(constants.Config.FILE).exists(): + # They are running reflex init for the first time. + return False + + existing_init_reflex_version = None + reflex_json = Path(constants.Dirs.REFLEX_JSON) + if reflex_json.exists(): + with reflex_json.open("r") as f: + data = json.load(f) existing_init_reflex_version = data.get("version", None) if existing_init_reflex_version is None: @@ -975,7 +982,9 @@ def show_rx_chakra_migration_instructions(): "[bold]Run `reflex script keep-chakra` to automatically update your app." ) console.log("") - console.log("For more details, please see https://TODO") # TODO add link to docs + console.log( + "For more details, please see https://reflex.dev/blog/2024-02-15-reflex-v0.4.0" + ) def migrate_to_rx_chakra():