installer.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. """File for constants related to the installation process. (Bun/Node)."""
  2. from __future__ import annotations
  3. import os
  4. from types import SimpleNamespace
  5. from .base import IS_WINDOWS
  6. from .utils import classproperty
  7. # Bun config.
  8. class Bun(SimpleNamespace):
  9. """Bun constants."""
  10. # The Bun version.
  11. VERSION = "1.2.4"
  12. # Min Bun Version
  13. MIN_VERSION = "1.2.4"
  14. # URL to bun install script.
  15. INSTALL_URL = "https://raw.githubusercontent.com/reflex-dev/reflex/main/scripts/bun_install.sh"
  16. # URL to windows install script.
  17. WINDOWS_INSTALL_URL = (
  18. "https://raw.githubusercontent.com/reflex-dev/reflex/main/scripts/install.ps1"
  19. )
  20. # Path of the bunfig file
  21. CONFIG_PATH = "bunfig.toml"
  22. @classproperty
  23. @classmethod
  24. def ROOT_PATH(cls):
  25. """The directory to store the bun.
  26. Returns:
  27. The directory to store the bun.
  28. """
  29. from reflex.config import environment
  30. return environment.REFLEX_DIR.get() / "bun"
  31. @classproperty
  32. @classmethod
  33. def DEFAULT_PATH(cls):
  34. """Default bun path.
  35. Returns:
  36. The default bun path.
  37. """
  38. return cls.ROOT_PATH / "bin" / ("bun" if not IS_WINDOWS else "bun.exe")
  39. DEFAULT_CONFIG = """
  40. [install]
  41. registry = "{registry}"
  42. """
  43. # Node / NPM config
  44. class Node(SimpleNamespace):
  45. """Node/ NPM constants."""
  46. # The Node version.
  47. VERSION = "22.11.0"
  48. # The minimum required node version.
  49. MIN_VERSION = "18.18.0"
  50. def _determine_nextjs_version() -> str:
  51. default_version = "15.2.4"
  52. if (version := os.getenv("NEXTJS_VERSION")) and version != default_version:
  53. from reflex.utils import console
  54. console.warn(
  55. f"You have requested next@{version} but the supported version is {default_version}, abandon all hope ye who enter here."
  56. )
  57. return version
  58. return default_version
  59. class PackageJson(SimpleNamespace):
  60. """Constants used to build the package.json file."""
  61. class Commands(SimpleNamespace):
  62. """The commands to define in package.json."""
  63. DEV = "next dev"
  64. EXPORT = "next build"
  65. EXPORT_SITEMAP = "next build && next-sitemap"
  66. PROD = "next start"
  67. PATH = "package.json"
  68. DEPENDENCIES = {
  69. "@emotion/react": "11.14.0",
  70. "axios": "1.8.3",
  71. "json5": "2.2.3",
  72. "next": _determine_nextjs_version(),
  73. "next-sitemap": "4.2.3",
  74. "next-themes": "0.4.6",
  75. "react": "19.0.0",
  76. "react-dom": "19.0.0",
  77. "react-focus-lock": "2.13.6",
  78. "socket.io-client": "4.8.1",
  79. "universal-cookie": "7.2.2",
  80. }
  81. DEV_DEPENDENCIES = {
  82. "autoprefixer": "10.4.21",
  83. "postcss": "8.5.3",
  84. "postcss-import": "16.1.0",
  85. }
  86. OVERRIDES = {
  87. # This should always match the `react` version in DEPENDENCIES for recharts compatibility.
  88. "react-is": "19.0.0"
  89. }