2018-07-03 18:34:25 +03:00
|
|
|
module Hasura.Server.Version
|
2018-07-27 12:34:50 +03:00
|
|
|
( currentVersion
|
2018-07-03 18:34:25 +03:00
|
|
|
, consoleVersion
|
2019-01-28 16:55:28 +03:00
|
|
|
, isDevVersion
|
2018-07-03 18:34:25 +03:00
|
|
|
)
|
|
|
|
where
|
|
|
|
|
|
|
|
import Control.Lens ((^.))
|
|
|
|
|
|
|
|
import qualified Data.SemVer as V
|
|
|
|
import qualified Data.Text as T
|
|
|
|
|
|
|
|
import Hasura.Prelude
|
2018-07-27 12:34:50 +03:00
|
|
|
import Hasura.Server.Utils (runScript)
|
2018-07-03 18:34:25 +03:00
|
|
|
|
|
|
|
version :: T.Text
|
2018-11-23 16:02:46 +03:00
|
|
|
version = T.dropWhileEnd (== '\n') $(runScript "../scripts/get-version.sh")
|
2018-07-03 18:34:25 +03:00
|
|
|
|
|
|
|
consoleVersion :: T.Text
|
2018-07-04 15:45:34 +03:00
|
|
|
consoleVersion = case V.fromText $ T.dropWhile (== 'v') version of
|
2018-07-03 18:34:25 +03:00
|
|
|
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
|
|
|
|
|
2018-07-27 12:34:50 +03:00
|
|
|
currentVersion :: T.Text
|
|
|
|
currentVersion = version
|
2019-01-28 16:55:28 +03:00
|
|
|
|
|
|
|
isDevVersion :: Bool
|
|
|
|
isDevVersion = either (const True) (const False) $
|
|
|
|
V.fromText $ T.dropWhile (== 'v') version
|