123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- """File for constants related to the installation process. (Bun/FNM/Node)."""
- from __future__ import annotations
- import platform
- from types import SimpleNamespace
- from .base import IS_WINDOWS, Reflex
- def get_fnm_name() -> str | None:
- """Get the appropriate fnm executable name based on the current platform.
- Returns:
- The fnm executable name for the current platform.
- """
- platform_os = platform.system()
- if platform_os == "Windows":
- return "fnm-windows"
- elif platform_os == "Darwin":
- return "fnm-macos"
- elif platform_os == "Linux":
- machine = platform.machine()
- if machine == "arm" or machine.startswith("armv7"):
- return "fnm-arm32"
- elif machine.startswith("aarch") or machine.startswith("armv8"):
- return "fnm-arm64"
- return "fnm-linux"
- return None
- # Bun config.
- class Bun(SimpleNamespace):
- """Bun constants."""
- # The Bun version.
- VERSION = "1.1.29"
- # Min Bun Version
- MIN_VERSION = "0.7.0"
- # The directory to store the bun.
- ROOT_PATH = Reflex.DIR / "bun"
- # Default bun path.
- DEFAULT_PATH = ROOT_PATH / "bin" / ("bun" if not IS_WINDOWS else "bun.exe")
- # URL to bun install script.
- INSTALL_URL = "https://raw.githubusercontent.com/reflex-dev/reflex/change-bun-link/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"
- # The environment variable to use the system installed bun.
- USE_SYSTEM_VAR = "REFLEX_USE_SYSTEM_BUN"
- # FNM config.
- class Fnm(SimpleNamespace):
- """FNM constants."""
- # The FNM version.
- VERSION = "1.35.1"
- # The directory to store fnm.
- DIR = Reflex.DIR / "fnm"
- FILENAME = get_fnm_name()
- # The fnm executable binary.
- EXE = DIR / ("fnm.exe" if IS_WINDOWS else "fnm")
- # The URL to the fnm release binary
- INSTALL_URL = (
- f"https://github.com/Schniz/fnm/releases/download/v{VERSION}/{FILENAME}.zip"
- )
- # Node / NPM config
- class Node(SimpleNamespace):
- """Node/ NPM constants."""
- # The Node version.
- VERSION = "20.18.0"
- # The minimum required node version.
- MIN_VERSION = "18.17.0"
- # The node bin path.
- BIN_PATH = (
- Fnm.DIR
- / "node-versions"
- / f"v{VERSION}"
- / "installation"
- / ("bin" if not IS_WINDOWS else "")
- )
- # The default path where node is installed.
- PATH = BIN_PATH / ("node.exe" if IS_WINDOWS else "node")
- # The default path where npm is installed.
- NPM_PATH = BIN_PATH / "npm"
- # The environment variable to use the system installed node.
- USE_SYSTEM_VAR = "REFLEX_USE_SYSTEM_NODE"
- class PackageJson(SimpleNamespace):
- """Constants used to build the package.json file."""
- class Commands(SimpleNamespace):
- """The commands to define in package.json."""
- DEV = "next dev"
- EXPORT = "next build"
- EXPORT_SITEMAP = "next build && next-sitemap"
- PROD = "next start"
- PATH = "package.json"
- DEPENDENCIES = {
- "@babel/standalone": "7.25.7",
- "@emotion/react": "11.13.3",
- "axios": "1.7.7",
- "json5": "2.2.3",
- "next": "14.2.14",
- "next-sitemap": "4.2.3",
- "next-themes": "0.3.0",
- "react": "18.3.1",
- "react-dom": "18.3.1",
- "react-focus-lock": "2.13.2",
- "socket.io-client": "4.8.0",
- "universal-cookie": "7.2.0",
- }
- DEV_DEPENDENCIES = {
- "autoprefixer": "10.4.20",
- "postcss": "8.4.47",
- "postcss-import": "16.1.0",
- }
|