installer.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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, Dirs, 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.3"
  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. # FNM config.
  41. class Fnm(SimpleNamespace):
  42. """FNM constants."""
  43. # The FNM version.
  44. VERSION = "1.35.1"
  45. # The directory to store fnm.
  46. DIR = os.path.join(Reflex.DIR, "fnm")
  47. FILENAME = get_fnm_name()
  48. # The fnm executable binary.
  49. EXE = os.path.join(DIR, "fnm.exe" if IS_WINDOWS else "fnm")
  50. # The URL to the fnm release binary
  51. INSTALL_URL = (
  52. f"https://github.com/Schniz/fnm/releases/download/v{VERSION}/{FILENAME}.zip"
  53. )
  54. # Node / NPM config
  55. class Node(SimpleNamespace):
  56. """Node/ NPM constants."""
  57. # The Node version.
  58. VERSION = "18.17.0"
  59. # The minimum required node version.
  60. MIN_VERSION = "18.17.0"
  61. # The node bin path.
  62. BIN_PATH = os.path.join(
  63. Fnm.DIR,
  64. "node-versions",
  65. f"v{VERSION}",
  66. "installation",
  67. "bin" if not IS_WINDOWS else "",
  68. )
  69. # The default path where node is installed.
  70. PATH = os.path.join(BIN_PATH, "node.exe" if IS_WINDOWS else "node")
  71. # The default path where npm is installed.
  72. NPM_PATH = os.path.join(BIN_PATH, "npm")
  73. class PackageJson(SimpleNamespace):
  74. """Constants used to build the package.json file."""
  75. class Commands(SimpleNamespace):
  76. """The commands to define in package.json."""
  77. DEV = "next dev"
  78. EXPORT = "next build"
  79. EXPORT_SITEMAP = "next build && next-sitemap"
  80. PROD = "next start"
  81. PATH = os.path.join(Dirs.WEB, "package.json")
  82. DEPENDENCIES = {
  83. "@emotion/react": "11.11.1",
  84. "axios": "1.6.0",
  85. "json5": "2.2.3",
  86. "next": "14.0.1",
  87. "next-sitemap": "4.1.8",
  88. "next-themes": "0.2.1",
  89. "react": "18.2.0",
  90. "react-dom": "18.2.0",
  91. "react-focus-lock": "2.11.3",
  92. "socket.io-client": "4.6.1",
  93. "universal-cookie": "4.0.4",
  94. }
  95. DEV_DEPENDENCIES = {
  96. "autoprefixer": "10.4.14",
  97. "postcss": "8.4.31",
  98. }