handle installing frontend packages more gracefully
This commit is contained in:
parent
2ba62a6d63
commit
f8169795f1
@ -930,15 +930,31 @@ def install_frontend_packages(packages: set[str], config: Config):
|
|||||||
"""
|
"""
|
||||||
# unsupported archs(arm and 32bit machines) will use npm anyway. so we dont have to run npm twice
|
# unsupported archs(arm and 32bit machines) will use npm anyway. so we dont have to run npm twice
|
||||||
fallback_command = (
|
fallback_command = (
|
||||||
get_package_manager()
|
get_package_manager(on_failure_return_none=True)
|
||||||
if not constants.IS_WINDOWS
|
if (
|
||||||
|
not constants.IS_WINDOWS
|
||||||
or constants.IS_WINDOWS
|
or constants.IS_WINDOWS
|
||||||
and is_windows_bun_supported()
|
and is_windows_bun_supported()
|
||||||
and not windows_check_onedrive_in_path()
|
and not windows_check_onedrive_in_path()
|
||||||
|
)
|
||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
install_package_manager = (
|
||||||
|
get_install_package_manager(on_failure_return_none=True) or fallback_command
|
||||||
|
)
|
||||||
|
|
||||||
|
if install_package_manager is None:
|
||||||
|
raise FileNotFoundError(
|
||||||
|
"Could not find a package manager to install frontend packages. You may need to run `reflex init`."
|
||||||
|
)
|
||||||
|
|
||||||
|
fallback_command = (
|
||||||
|
fallback_command if fallback_command is not install_package_manager else None
|
||||||
|
)
|
||||||
|
|
||||||
processes.run_process_with_fallback(
|
processes.run_process_with_fallback(
|
||||||
[get_install_package_manager(), "install"], # type: ignore
|
[install_package_manager, "install"], # type: ignore
|
||||||
fallback=fallback_command,
|
fallback=fallback_command,
|
||||||
analytics_enabled=True,
|
analytics_enabled=True,
|
||||||
show_status_message="Installing base frontend packages",
|
show_status_message="Installing base frontend packages",
|
||||||
@ -949,7 +965,7 @@ def install_frontend_packages(packages: set[str], config: Config):
|
|||||||
if config.tailwind is not None:
|
if config.tailwind is not None:
|
||||||
processes.run_process_with_fallback(
|
processes.run_process_with_fallback(
|
||||||
[
|
[
|
||||||
get_install_package_manager(),
|
install_package_manager,
|
||||||
"add",
|
"add",
|
||||||
"-d",
|
"-d",
|
||||||
constants.Tailwind.VERSION,
|
constants.Tailwind.VERSION,
|
||||||
@ -965,7 +981,7 @@ def install_frontend_packages(packages: set[str], config: Config):
|
|||||||
# Install custom packages defined in frontend_packages
|
# Install custom packages defined in frontend_packages
|
||||||
if len(packages) > 0:
|
if len(packages) > 0:
|
||||||
processes.run_process_with_fallback(
|
processes.run_process_with_fallback(
|
||||||
[get_install_package_manager(), "add", *packages],
|
[install_package_manager, "add", *packages],
|
||||||
fallback=fallback_command,
|
fallback=fallback_command,
|
||||||
analytics_enabled=True,
|
analytics_enabled=True,
|
||||||
show_status_message="Installing frontend packages from config and components",
|
show_status_message="Installing frontend packages from config and components",
|
||||||
|
Loading…
Reference in New Issue
Block a user