mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 12:31:52 +03:00
36 lines
887 B
Haskell
36 lines
887 B
Haskell
module Hasura.Server.Version
|
|
( currentVersion
|
|
, consoleVersion
|
|
, isDevVersion
|
|
)
|
|
where
|
|
|
|
import Control.Lens ((^.))
|
|
|
|
import qualified Data.SemVer as V
|
|
import qualified Data.Text as T
|
|
|
|
import Hasura.Prelude
|
|
import Hasura.Server.Utils (runScript)
|
|
|
|
version :: T.Text
|
|
version = T.dropWhileEnd (== '\n') $(runScript "../scripts/get-version.sh")
|
|
|
|
consoleVersion :: T.Text
|
|
consoleVersion = case V.fromText $ T.dropWhile (== 'v') version of
|
|
Right ver -> mkVersion ver
|
|
Left _ -> version
|
|
|
|
mkVersion :: V.Version -> T.Text
|
|
mkVersion ver = T.pack $ "v" ++ show major ++ "." ++ show minor
|
|
where
|
|
major = ver ^. V.major
|
|
minor = ver ^. V.minor
|
|
|
|
currentVersion :: T.Text
|
|
currentVersion = version
|
|
|
|
isDevVersion :: Bool
|
|
isDevVersion = either (const True) (const False) $
|
|
V.fromText $ T.dropWhile (== 'v') version
|