Compare commits

...

5 Commits

Author SHA1 Message Date
Elijah
3d13baba9b fix precommit 2023-11-02 16:07:26 +00:00
Elijah
72d94cad22 show logs for debug mode 2023-11-02 15:48:43 +00:00
Elijah
3e535aa42a fix precommit 2023-11-02 12:44:41 +00:00
Elijah
3be509975f use npm prefer-offline flag to reduce reload time 2023-11-02 12:42:05 +00:00
Elijah
42dbd4c959 REF-1050/Investigate Windows Hot reload 2023-11-02 12:41:10 +00:00
4 changed files with 25 additions and 8 deletions

View File

@ -201,6 +201,9 @@ class Config(Base):
# The worker class used in production mode
gunicorn_worker_class: str = "uvicorn.workers.UvicornH11Worker"
# npm prefer-offline flag to prefer local cache.
npm_prefer_offline: bool = False
# Attributes that were explicitly set by the user.
_non_default_attributes: Set[str] = pydantic.PrivateAttr(set())

View File

@ -68,6 +68,7 @@ class Config(Base):
rxdeploy_url: Optional[str]
cp_backend_url: str
cp_web_url: str
npm_prefer_offline: bool
username: Optional[str]
gunicorn_worker_class: str
@ -95,6 +96,7 @@ class Config(Base):
rxdeploy_url: Optional[str] = None,
cp_backend_url: Optional[str] = None,
cp_web_url: Optional[str] = None,
npm_prefer_offline: bool = False,
username: Optional[str] = None,
gunicorn_worker_class: Optional[str] = None,
**kwargs

View File

@ -116,5 +116,5 @@ class PackageJson(SimpleNamespace):
}
DEV_DEPENDENCIES = {
"autoprefixer": "10.4.14",
"postcss": "8.4.24",
"postcss": "8.4.31",
}

View File

@ -514,37 +514,49 @@ def install_frontend_packages(packages: set[str]):
Example:
>>> install_frontend_packages(["react", "react-dom"])
"""
config = get_config()
package_manager = get_install_package_manager()
uses_npm = package_manager.endswith("npm") if package_manager else False
prefer_offline = (
["--prefer-offline"] if config.npm_prefer_offline and uses_npm else []
)
# show logs for debug mode.
show_logs = config.loglevel >= constants.LogLevel.DEBUG
# Install the base packages.
process = processes.new_process(
[get_install_package_manager(), "install", "--loglevel", "silly"],
[package_manager, "install", "--loglevel", "silly", *prefer_offline],
cwd=constants.Dirs.WEB,
shell=constants.IS_WINDOWS,
show_logs=show_logs,
)
processes.show_status("Installing base frontend packages", process)
config = get_config()
if config.tailwind is not None:
# install tailwind and tailwind plugins as dev dependencies.
process = processes.new_process(
[
get_install_package_manager(),
package_manager,
"add",
"-d",
*prefer_offline,
constants.Tailwind.VERSION,
*((config.tailwind or {}).get("plugins", [])),
*(config.tailwind or {}).get("plugins", []),
],
cwd=constants.Dirs.WEB,
shell=constants.IS_WINDOWS,
show_logs=show_logs,
)
processes.show_status("Installing tailwind", process)
# Install custom packages defined in frontend_packages
if len(packages) > 0:
process = processes.new_process(
[get_install_package_manager(), "add", *packages],
[package_manager, "add", *packages, *prefer_offline],
cwd=constants.Dirs.WEB,
shell=constants.IS_WINDOWS,
show_logs=show_logs,
)
processes.show_status(
"Installing frontend packages from config and components", process