1
0
mirror of https://github.com/hasura/graphql-engine.git synced 2024-12-16 09:51:59 +03:00
graphql-engine/server/src-lib/Hasura/Server/Version.hs

34 lines
813 B
Haskell

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Hasura.Server.Version
( currentVersion
, consoleVersion
)
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