123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- """File for constants related to the installation process. (Bun/Node)."""
- from __future__ import annotations
- import os
- from types import SimpleNamespace
- from .base import IS_WINDOWS
- from .utils import classproperty
- # Bun config.
- class Bun(SimpleNamespace):
- """Bun constants."""
- # The Bun version.
- VERSION = "1.2.12"
- # Min Bun Version
- MIN_VERSION = "1.2.8"
- # URL to bun install script.
- INSTALL_URL = "https://raw.githubusercontent.com/reflex-dev/reflex/main/scripts/bun_install.sh"
- # URL to windows install script.
- WINDOWS_INSTALL_URL = (
- "https://raw.githubusercontent.com/reflex-dev/reflex/main/scripts/install.ps1"
- )
- # Path of the bunfig file
- CONFIG_PATH = "bunfig.toml"
- @classproperty
- @classmethod
- def ROOT_PATH(cls):
- """The directory to store the bun.
- Returns:
- The directory to store the bun.
- """
- from reflex.config import environment
- return environment.REFLEX_DIR.get() / "bun"
- @classproperty
- @classmethod
- def DEFAULT_PATH(cls):
- """Default bun path.
- Returns:
- The default bun path.
- """
- return cls.ROOT_PATH / "bin" / ("bun" if not IS_WINDOWS else "bun.exe")
- DEFAULT_CONFIG = """
- [install]
- registry = "{registry}"
- """
- # Node / NPM config
- class Node(SimpleNamespace):
- """Node/ NPM constants."""
- # The minimum required node version.
- MIN_VERSION = "18.18.0"
- # Path of the node config file.
- CONFIG_PATH = ".npmrc"
- DEFAULT_CONFIG = """
- registry={registry}
- fetch-retries=0
- """
- def _determine_nextjs_version() -> str:
- default_version = "15.3.2"
- if (version := os.getenv("NEXTJS_VERSION")) and version != default_version:
- from reflex.utils import console
- console.warn(
- f"You have requested next@{version} but the supported version is {default_version}, abandon all hope ye who enter here."
- )
- return version
- return default_version
- def _determine_react_version() -> str:
- default_version = "19.1.0"
- if (version := os.getenv("REACT_VERSION")) and version != default_version:
- from reflex.utils import console
- console.warn(
- f"You have requested react@{version} but the supported version is {default_version}, abandon all hope ye who enter here."
- )
- return version
- return default_version
- class PackageJson(SimpleNamespace):
- """Constants used to build the package.json file."""
- class Commands(SimpleNamespace):
- """The commands to define in package.json."""
- DEV = "next dev {flags}"
- EXPORT = "next build {flags}"
- EXPORT_SITEMAP = "next build {flags} && next-sitemap"
- PROD = "next start"
- PATH = "package.json"
- _react_version = _determine_react_version()
- DEPENDENCIES = {
- "@emotion/react": "11.14.0",
- "axios": "1.9.0",
- "json5": "2.2.3",
- "next": _determine_nextjs_version(),
- "next-sitemap": "4.2.3",
- "next-themes": "0.4.6",
- "react": _react_version,
- "react-dom": _react_version,
- "react-focus-lock": "2.13.6",
- "socket.io-client": "4.8.1",
- "universal-cookie": "7.2.2",
- }
- DEV_DEPENDENCIES = {
- "autoprefixer": "10.4.21",
- "postcss": "8.5.3",
- "postcss-import": "16.1.0",
- }
- OVERRIDES = {
- # This should always match the `react` version in DEPENDENCIES for recharts compatibility.
- "react-is": _react_version
- }
|