1
0

installer.py 3.4 KB

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