Compare commits

...

4 Commits

Author SHA1 Message Date
Masen Furer
6c4a4a9e79
run bun from cached path 2025-01-09 11:58:08 -08:00
Masen Furer
60286590c7
check bun pm ls before bouncing server 2025-01-09 10:17:36 -08:00
Masen Furer
be30878c84
debugging: show before and after packages 2025-01-08 17:58:44 -08:00
Masen Furer
3ba0f558a3
debuggin info 2025-01-08 17:58:44 -08:00
2 changed files with 47 additions and 5 deletions

View File

@ -18,7 +18,7 @@ from reflex import constants
from reflex.config import environment, get_config
from reflex.constants.base import LogLevel
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)
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
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
first_run = True
@ -114,7 +121,7 @@ def run_process_and_launch_url(run_command: list[str], backend_present=True):
notify_backend()
first_run = False
else:
console.print("New packages detected: Updating app...")
console.print(f"New packages detected: Updating app... {line}")
else:
if any(
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)
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
kill(process.pid)
process = None
break # for line in process.stdout
new_packages = get_package_list()
if new_packages != last_packages:
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:
break # while True

View File

@ -267,6 +267,30 @@ def windows_npm_escape_hatch() -> bool:
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:
"""Get the app module based on the default config.