Compare commits
5 Commits
main
...
REF-1050/p
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3d13baba9b | ||
![]() |
72d94cad22 | ||
![]() |
3e535aa42a | ||
![]() |
3be509975f | ||
![]() |
42dbd4c959 |
@ -201,6 +201,9 @@ class Config(Base):
|
|||||||
# The worker class used in production mode
|
# The worker class used in production mode
|
||||||
gunicorn_worker_class: str = "uvicorn.workers.UvicornH11Worker"
|
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.
|
# Attributes that were explicitly set by the user.
|
||||||
_non_default_attributes: Set[str] = pydantic.PrivateAttr(set())
|
_non_default_attributes: Set[str] = pydantic.PrivateAttr(set())
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ class Config(Base):
|
|||||||
rxdeploy_url: Optional[str]
|
rxdeploy_url: Optional[str]
|
||||||
cp_backend_url: str
|
cp_backend_url: str
|
||||||
cp_web_url: str
|
cp_web_url: str
|
||||||
|
npm_prefer_offline: bool
|
||||||
username: Optional[str]
|
username: Optional[str]
|
||||||
gunicorn_worker_class: str
|
gunicorn_worker_class: str
|
||||||
|
|
||||||
@ -95,6 +96,7 @@ class Config(Base):
|
|||||||
rxdeploy_url: Optional[str] = None,
|
rxdeploy_url: Optional[str] = None,
|
||||||
cp_backend_url: Optional[str] = None,
|
cp_backend_url: Optional[str] = None,
|
||||||
cp_web_url: Optional[str] = None,
|
cp_web_url: Optional[str] = None,
|
||||||
|
npm_prefer_offline: bool = False,
|
||||||
username: Optional[str] = None,
|
username: Optional[str] = None,
|
||||||
gunicorn_worker_class: Optional[str] = None,
|
gunicorn_worker_class: Optional[str] = None,
|
||||||
**kwargs
|
**kwargs
|
||||||
|
@ -116,5 +116,5 @@ class PackageJson(SimpleNamespace):
|
|||||||
}
|
}
|
||||||
DEV_DEPENDENCIES = {
|
DEV_DEPENDENCIES = {
|
||||||
"autoprefixer": "10.4.14",
|
"autoprefixer": "10.4.14",
|
||||||
"postcss": "8.4.24",
|
"postcss": "8.4.31",
|
||||||
}
|
}
|
||||||
|
@ -514,37 +514,49 @@ def install_frontend_packages(packages: set[str]):
|
|||||||
Example:
|
Example:
|
||||||
>>> install_frontend_packages(["react", "react-dom"])
|
>>> 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.
|
# Install the base packages.
|
||||||
process = processes.new_process(
|
process = processes.new_process(
|
||||||
[get_install_package_manager(), "install", "--loglevel", "silly"],
|
[package_manager, "install", "--loglevel", "silly", *prefer_offline],
|
||||||
cwd=constants.Dirs.WEB,
|
cwd=constants.Dirs.WEB,
|
||||||
shell=constants.IS_WINDOWS,
|
shell=constants.IS_WINDOWS,
|
||||||
|
show_logs=show_logs,
|
||||||
)
|
)
|
||||||
|
|
||||||
processes.show_status("Installing base frontend packages", process)
|
processes.show_status("Installing base frontend packages", process)
|
||||||
|
|
||||||
config = get_config()
|
|
||||||
if config.tailwind is not None:
|
if config.tailwind is not None:
|
||||||
# install tailwind and tailwind plugins as dev dependencies.
|
|
||||||
process = processes.new_process(
|
process = processes.new_process(
|
||||||
[
|
[
|
||||||
get_install_package_manager(),
|
package_manager,
|
||||||
"add",
|
"add",
|
||||||
"-d",
|
"-d",
|
||||||
|
*prefer_offline,
|
||||||
constants.Tailwind.VERSION,
|
constants.Tailwind.VERSION,
|
||||||
*((config.tailwind or {}).get("plugins", [])),
|
*(config.tailwind or {}).get("plugins", []),
|
||||||
],
|
],
|
||||||
cwd=constants.Dirs.WEB,
|
cwd=constants.Dirs.WEB,
|
||||||
shell=constants.IS_WINDOWS,
|
shell=constants.IS_WINDOWS,
|
||||||
|
show_logs=show_logs,
|
||||||
)
|
)
|
||||||
processes.show_status("Installing tailwind", process)
|
processes.show_status("Installing tailwind", process)
|
||||||
|
|
||||||
# Install custom packages defined in frontend_packages
|
|
||||||
if len(packages) > 0:
|
if len(packages) > 0:
|
||||||
process = processes.new_process(
|
process = processes.new_process(
|
||||||
[get_install_package_manager(), "add", *packages],
|
[package_manager, "add", *packages, *prefer_offline],
|
||||||
cwd=constants.Dirs.WEB,
|
cwd=constants.Dirs.WEB,
|
||||||
shell=constants.IS_WINDOWS,
|
shell=constants.IS_WINDOWS,
|
||||||
|
show_logs=show_logs,
|
||||||
)
|
)
|
||||||
processes.show_status(
|
processes.show_status(
|
||||||
"Installing frontend packages from config and components", process
|
"Installing frontend packages from config and components", process
|
||||||
|
Loading…
Reference in New Issue
Block a user