Compare commits
4 Commits
main
...
masenf/new
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6c4a4a9e79 | ||
![]() |
60286590c7 | ||
![]() |
be30878c84 | ||
![]() |
3ba0f558a3 |
@ -18,7 +18,7 @@ from reflex import constants
|
|||||||
from reflex.config import environment, get_config
|
from reflex.config import environment, get_config
|
||||||
from reflex.constants.base import LogLevel
|
from reflex.constants.base import LogLevel
|
||||||
from reflex.utils import console, path_ops
|
from reflex.utils import console, path_ops
|
||||||
from reflex.utils.prerequisites import get_web_dir
|
from reflex.utils.prerequisites import get_package_list, get_web_dir
|
||||||
|
|
||||||
# For uvicorn windows bug fix (#2335)
|
# For uvicorn windows bug fix (#2335)
|
||||||
frontend_process = None
|
frontend_process = None
|
||||||
@ -82,6 +82,13 @@ def run_process_and_launch_url(run_command: list[str], backend_present=True):
|
|||||||
|
|
||||||
json_file_path = get_web_dir() / constants.PackageJson.PATH
|
json_file_path = get_web_dir() / constants.PackageJson.PATH
|
||||||
last_hash = detect_package_change(json_file_path)
|
last_hash = detect_package_change(json_file_path)
|
||||||
|
console.print(
|
||||||
|
f"DETECT_PACKAGE_CHANGE init {last_hash}, {json.dumps(json.loads(json_file_path.read_text()))}"
|
||||||
|
)
|
||||||
|
last_packages = get_package_list()
|
||||||
|
console.print(
|
||||||
|
f"DETECT_PACKAGE_CHANGE init {last_packages}",
|
||||||
|
)
|
||||||
process = None
|
process = None
|
||||||
first_run = True
|
first_run = True
|
||||||
|
|
||||||
@ -114,7 +121,7 @@ def run_process_and_launch_url(run_command: list[str], backend_present=True):
|
|||||||
notify_backend()
|
notify_backend()
|
||||||
first_run = False
|
first_run = False
|
||||||
else:
|
else:
|
||||||
console.print("New packages detected: Updating app...")
|
console.print(f"New packages detected: Updating app... {line}")
|
||||||
else:
|
else:
|
||||||
if any(
|
if any(
|
||||||
x in line for x in ("bin executable does not exist on disk",)
|
x in line for x in ("bin executable does not exist on disk",)
|
||||||
@ -126,10 +133,21 @@ def run_process_and_launch_url(run_command: list[str], backend_present=True):
|
|||||||
)
|
)
|
||||||
new_hash = detect_package_change(json_file_path)
|
new_hash = detect_package_change(json_file_path)
|
||||||
if new_hash != last_hash:
|
if new_hash != last_hash:
|
||||||
|
new_content = json.dumps(json.loads(json_file_path.read_text()))
|
||||||
|
console.print(
|
||||||
|
f"DETECT_PACKAGE_CHANGE hit {last_hash} != {new_hash} (new), {new_content}"
|
||||||
|
)
|
||||||
last_hash = new_hash
|
last_hash = new_hash
|
||||||
kill(process.pid)
|
new_packages = get_package_list()
|
||||||
process = None
|
if new_packages != last_packages:
|
||||||
break # for line in process.stdout
|
console.print("Reloading app due to new content...")
|
||||||
|
console.print(
|
||||||
|
f"DETECT_PACKAGE_CHANGE init {new_packages}",
|
||||||
|
)
|
||||||
|
last_packages = new_packages
|
||||||
|
kill(process.pid)
|
||||||
|
process = None
|
||||||
|
break # for line in process.stdout
|
||||||
if process is not None:
|
if process is not None:
|
||||||
break # while True
|
break # while True
|
||||||
|
|
||||||
|
@ -267,6 +267,30 @@ def windows_npm_escape_hatch() -> bool:
|
|||||||
return environment.REFLEX_USE_NPM.get()
|
return environment.REFLEX_USE_NPM.get()
|
||||||
|
|
||||||
|
|
||||||
|
def get_package_list() -> str:
|
||||||
|
"""Get the list of installed packages in the current environment.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The list of user and framework installed packages.
|
||||||
|
"""
|
||||||
|
package_manager = get_package_manager()
|
||||||
|
install_package_manager = get_install_package_manager()
|
||||||
|
if package_manager == install_package_manager:
|
||||||
|
# npm
|
||||||
|
cmd = [install_package_manager, "list"]
|
||||||
|
else:
|
||||||
|
# bun
|
||||||
|
cmd = [install_package_manager, "pm", "ls"]
|
||||||
|
return (
|
||||||
|
processes.new_process(
|
||||||
|
cmd,
|
||||||
|
cwd=get_web_dir(),
|
||||||
|
)
|
||||||
|
.stdout.read()
|
||||||
|
.strip()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_app(reload: bool = False) -> ModuleType:
|
def get_app(reload: bool = False) -> ModuleType:
|
||||||
"""Get the app module based on the default config.
|
"""Get the app module based on the default config.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user