packages feed

json-spec-elm-servant 0.4.0.0 → 0.4.0.1

raw patch · 3 files changed

+36/−80 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

json-spec-elm-servant.cabal view
@@ -1,6 +1,6 @@ cabal-version:       3.0 name:                json-spec-elm-servant-version:             0.4.0.0+version:             0.4.0.1 synopsis:            Generated elm code for servant APIs. description:         Generate Elm encoders, decoders, and API requests                      for an Servant API, where the shape of the data@@ -37,7 +37,6 @@     -Wmissing-export-lists     -Wmissing-import-lists     -Wredundant-constraints-    -Wunused-packages  library   import: dependencies, warnings@@ -47,17 +46,22 @@   -- other-extensions:       hs-source-dirs:      src   default-language:    Haskell2010+  ghc-options:+    -Wunused-packages   build-depends:     , bound         >= 2.0.7   && < 2.1     , http-types    >= 0.12.3  && < 0.13     , json-spec-elm >= 0.4.0.0 && < 0.5     , mtl           >= 2.3.1   && < 2.4 +flag compile-elm+  description:+    Set this flag to run the Elm compilation tests, which requires Elm+    to be installed on the system.+  default: False -test-suite test+test-suite compile-elm   import: dependencies, warnings-  main-is: test.hs-  type: exitcode-stdio-1.0   hs-source-dirs: test   default-language: Haskell2010   other-modules:@@ -75,4 +79,9 @@     , time                 >= 1.12.2   && < 1.13     , unordered-containers >= 0.2.19.1 && < 0.3     , uuid                 >= 1.3.15   && < 1.4-+  if flag(compile-elm)+    main-is: test.hs+    type: exitcode-stdio-1.0+  else+    main-is: test-pass.hs+    type: exitcode-stdio-1.0
+ test/test-pass.hs view
@@ -0,0 +1,21 @@++{-|+  A "test" that always passes, so that systems that don't have Elm+  installed can still run the tests (as, for instance, in some kind of+  CI workflow that always runs  the tests for all dependencies).+-}+module Main (main) where++main :: IO ()+main =+  putStrLn $+    unlines+      [ ""+      , ""+      , "    NB! We are _NOT_ running the tests really because the `compile-elm`"+      , "    flag is not set. If you are sure that the proper Elm tools are"+      , "    installed on the system, then you can set the `compile-elm` flag"+      , "    and real tests will be run"+      , ""+      , ""+      ]
− test/test.hs
@@ -1,74 +0,0 @@-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TypeApplications #-}--module Main (main) where--import Api (Api)-import Data.Foldable (traverse_)-import Data.HashMap.Strict (HashMap)-import Data.JsonSpec.Elm.Servant (servantDefs)-import Data.Proxy (Proxy(Proxy))-import Data.Text (Text)-import Language.Elm.Name (Module)-import Language.Elm.Pretty (modules)-import Prelude (Bool(True), Functor(fmap), Semigroup((<>)), ($), (.),-  FilePath, IO, init)-import Prettyprinter (defaultLayoutOptions, layoutPretty)-import Prettyprinter.Render.Text (renderStrict)-import Servant.API (ToServantApi)-import System.Directory (createDirectoryIfMissing)-import System.Process (callCommand)-import Test.Hspec (describe, hspec, it)-import qualified Data.HashMap.Strict as HM-import qualified Data.Set as Set-import qualified Data.Text as Text-import qualified Data.Text.IO as TIO--main :: IO ()-main =-  hspec $ do-    describe "thing" $ do-      it "works" $-        let-          actual :: HashMap Module Text-          actual =-            fmap ((<> "\n") . renderStrict . layoutPretty defaultLayoutOptions)-            . modules-            . Set.toList-            $ servantDefs (Proxy @(ToServantApi Api))--        in do-          traverse_ writeModule (HM.toList actual)-          callCommand "(cd elm-test; elm-format src/ --yes)"-          callCommand-            "(\-              \cd elm-test; \-              \yes Y | (\-                \elm init; \-                \elm install rtfeldman/elm-iso8601-date-strings; \-                \elm install elm/json; \-                \elm install elm/url; \-                \elm install elm/time; \-                \elm install elm/http\-              \); \-              \elm make src/Api/Req.elm\-            \)"-          callCommand "rm -rf elm-test"---writeModule :: (Module, Text) -> IO ()-writeModule (module_, content) = do-    createDirectoryIfMissing True dirname-    TIO.writeFile filename content-  where-    pathName :: [Text] -> FilePath-    pathName = ("elm-test/src/" <>) . Text.unpack . Text.intercalate "/"--    filename :: FilePath-    filename = pathName module_ <> ".elm"--    dirname :: FilePath-    dirname = pathName (init module_)--