installer.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. """File for constants related to the installation process. (Bun/FNM/Node)."""
  2. from __future__ import annotations
  3. import platform
  4. from types import SimpleNamespace
  5. from .base import IS_WINDOWS, Reflex
  6. def get_fnm_name() -> str | None:
  7. """Get the appropriate fnm executable name based on the current platform.
  8. Returns:
  9. The fnm executable name for the current platform.
  10. """
  11. platform_os = platform.system()
  12. if platform_os == "Windows":
  13. return "fnm-windows"
  14. elif platform_os == "Darwin":
  15. return "fnm-macos"
  16. elif platform_os == "Linux":
  17. machine = platform.machine()
  18. if machine == "arm" or machine.startswith("armv7"):
  19. return "fnm-arm32"
  20. elif machine.startswith("aarch") or machine.startswith("armv8"):
  21. return "fnm-arm64"
  22. return "fnm-linux"
  23. return None
  24. # Bun config.
  25. class Bun(SimpleNamespace):
  26. """Bun constants."""
  27. # The Bun version.
  28. VERSION = "1.1.29"
  29. # Min Bun Version
  30. MIN_VERSION = "0.7.0"
  31. # The directory to store the bun.
  32. ROOT_PATH = Reflex.DIR / "bun"
  33. # Default bun path.
  34. DEFAULT_PATH = ROOT_PATH / "bin" / ("bun" if not IS_WINDOWS else "bun.exe")
  35. # URL to bun install script.
  36. INSTALL_URL = "https://raw.githubusercontent.com/reflex-dev/reflex/change-bun-link/scripts/bun_install.sh"
  37. # URL to windows install script.
  38. WINDOWS_INSTALL_URL = (
  39. "https://raw.githubusercontent.com/reflex-dev/reflex/main/scripts/install.ps1"
  40. )
  41. # Path of the bunfig file
  42. CONFIG_PATH = "bunfig.toml"
  43. # The environment variable to use the system installed bun.
  44. USE_SYSTEM_VAR = "REFLEX_USE_SYSTEM_BUN"
  45. # FNM config.
  46. class Fnm(SimpleNamespace):
  47. """FNM constants."""
  48. # The FNM version.
  49. VERSION = "1.35.1"
  50. # The directory to store fnm.
  51. DIR = Reflex.DIR / "fnm"
  52. FILENAME = get_fnm_name()
  53. # The fnm executable binary.
  54. EXE = DIR / ("fnm.exe" if IS_WINDOWS else "fnm")
  55. # The URL to the fnm release binary
  56. INSTALL_URL = (
  57. f"https://github.com/Schniz/fnm/releases/download/v{VERSION}/{FILENAME}.zip"
  58. )
  59. # Node / NPM config
  60. class Node(SimpleNamespace):
  61. """Node/ NPM constants."""
  62. # The Node version.
  63. VERSION = "20.18.0"
  64. # The minimum required node version.
  65. MIN_VERSION = "18.17.0"
  66. # The node bin path.
  67. BIN_PATH = (
  68. Fnm.DIR
  69. / "node-versions"
  70. / f"v{VERSION}"
  71. / "installation"
  72. / ("bin" if not IS_WINDOWS else "")
  73. )
  74. # The default path where node is installed.
  75. PATH = BIN_PATH / ("node.exe" if IS_WINDOWS else "node")
  76. # The default path where npm is installed.
  77. NPM_PATH = BIN_PATH / "npm"
  78. # The environment variable to use the system installed node.
  79. USE_SYSTEM_VAR = "REFLEX_USE_SYSTEM_NODE"
  80. class PackageJson(SimpleNamespace):
  81. """Constants used to build the package.json file."""
  82. class Commands(SimpleNamespace):
  83. """The commands to define in package.json."""
  84. DEV = "next dev"
  85. EXPORT = "next build"
  86. EXPORT_SITEMAP = "next build && next-sitemap"
  87. PROD = "next start"
  88. PATH = "package.json"
  89. DEPENDENCIES = {
  90. "@babel/standalone": "7.25.7",
  91. "@emotion/react": "11.13.3",
  92. "axios": "1.7.7",
  93. "json5": "2.2.3",
  94. "next": "14.2.14",
  95. "next-sitemap": "4.2.3",
  96. "next-themes": "0.3.0",
  97. "react": "18.3.1",
  98. "react-dom": "18.3.1",
  99. "react-focus-lock": "2.13.2",
  100. "socket.io-client": "4.8.0",
  101. "universal-cookie": "7.2.0",
  102. }
  103. DEV_DEPENDENCIES = {
  104. "autoprefixer": "10.4.20",
  105. "postcss": "8.4.47",
  106. "postcss-import": "16.1.0",
  107. }