From 87d58d37f3976caffe660bf4c2fa32881663f19c Mon Sep 17 00:00:00 2001 From: David Johnson Date: Wed, 4 Jul 2018 15:28:55 -0400 Subject: [PATCH] Default to http-client --- .gitignore | 1 + .travis.yml | 19 ++--------- default.nix | 18 ++++++---- stripe-core/default.nix | 2 +- stripe-core/stripe-core.cabal | 2 +- stripe-haskell/default.nix | 6 ++-- .../Web/Stripe/Client/Stripe.hs | 3 ++ .../Web/Stripe/Client/Stripe.hs~ | 0 stripe-haskell/stripe-haskell.cabal | 33 +++++++++++++------ stripe-http-client/default.nix | 21 ++++++++++++ .../src/Web/Stripe/Client/HttpClient.hs | 5 +++ stripe-http-client/stripe-http-client.cabal | 4 +-- stripe-http-client/tests/Main.hs | 5 +++ stripe-http-streams/default.nix | 2 +- stripe-http-streams/stripe-http-streams.cabal | 4 +-- stripe-tests/default.nix | 2 +- stripe-tests/stripe-tests.cabal | 4 +-- 17 files changed, 86 insertions(+), 45 deletions(-) create mode 100644 stripe-haskell/src-http-client/Web/Stripe/Client/Stripe.hs create mode 100644 stripe-haskell/src-http-client/Web/Stripe/Client/Stripe.hs~ create mode 100644 stripe-http-client/default.nix diff --git a/.gitignore b/.gitignore index a5aa4a9..e993b9b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ cabal.sandbox.config .stack-work result result-* +*~ diff --git a/.travis.yml b/.travis.yml index fabdde5..aa3f796 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,26 +3,13 @@ language: nix matrix: fast_finish: true include: - - env: GHCVER=ghc7103 - - env: GHCVER=ghc802 - - env: GHCVER=ghc822 - - env: GHCVER=ghc742 - - env: GHCVER=ghc763 - - env: GHCVER=ghc783 - - env: GHCVER=ghc784 - - env: GHCVER=ghc801 - env: GHCVER=ghc802 - env: GHCVER=ghc822 + - env: GHCVER=ghc842 - env: GHCVER=ghcHEAD allow_failures: - - env: GHCVER=ghc742 - - env: GHCVER=ghc763 - - env: GHCVER=ghc783 - - env: GHCVER=ghc784 - - env: GHCVER=ghc7103 - - env: GHCVER=ghc801 - env: GHCVER=ghc802 - - env: GHCVER=ghc822 + - env: GHCVER=ghc842 - env: GHCVER=ghcHEAD before_install: @@ -30,4 +17,4 @@ before_install: - nix-channel --update script: - - nix-build -A stripe-haskell --argstr compiler $GHCVER + - nix-build -A stripe-haskell --argstr compiler $GHCVER --arg check true diff --git a/default.nix b/default.nix index 65fbd81..ad31c87 100644 --- a/default.nix +++ b/default.nix @@ -1,18 +1,24 @@ -{ compiler ? "ghc822" }: +{ compiler ? "ghc822", check ? false }: let config = { - packageOverrides = pkgs: { + packageOverrides = pkgs: with pkgs.haskell.lib; { haskell = pkgs.haskell // { packages = pkgs.haskell.packages // { ${compiler} = pkgs.haskell.packages.${compiler}.override { overrides = self: super: with pkgs.haskell.lib; rec { stripe-core = self.callPackage ./stripe-core {}; stripe-tests = self.callPackage ./stripe-tests { inherit stripe-core; }; - stripe-http-streams = self.callPackage ./stripe-http-streams { + stripe-http-streams = dontCheck (self.callPackage ./stripe-http-streams { inherit stripe-tests stripe-core; - }; + }); + stripe-http-client = + let + stripe-http-client = self.callPackage ./stripe-http-client { + inherit stripe-tests stripe-core; + }; + in if check then stripe-http-client else dontCheck stripe-http-client; stripe-haskell = self.callPackage ./stripe-haskell { - inherit stripe-http-streams stripe-core; + inherit stripe-http-streams stripe-core stripe-http-client; }; }; }; @@ -22,6 +28,6 @@ let }; in with (import { inherit config; }).haskell.packages.${compiler}; { - inherit stripe-core stripe-tests stripe-haskell stripe-http-streams; + inherit stripe-core stripe-tests stripe-haskell stripe-http-streams stripe-http-client; } diff --git a/stripe-core/default.nix b/stripe-core/default.nix index d1a68de..5345c6b 100644 --- a/stripe-core/default.nix +++ b/stripe-core/default.nix @@ -3,7 +3,7 @@ }: mkDerivation { pname = "stripe-core"; - version = "2.3.0"; + version = "2.4.0"; src = ./.; libraryHaskellDepends = [ aeson base bytestring mtl text time transformers diff --git a/stripe-core/stripe-core.cabal b/stripe-core/stripe-core.cabal index 4278636..21b1c4a 100644 --- a/stripe-core/stripe-core.cabal +++ b/stripe-core/stripe-core.cabal @@ -1,5 +1,5 @@ name: stripe-core -version: 2.3.0 +version: 2.4.0 synopsis: Stripe API for Haskell - Pure Core license: MIT license-file: LICENSE diff --git a/stripe-haskell/default.nix b/stripe-haskell/default.nix index cfb2d71..6061e40 100644 --- a/stripe-haskell/default.nix +++ b/stripe-haskell/default.nix @@ -1,9 +1,9 @@ -{ mkDerivation, base, stdenv, stripe-core, stripe-http-streams }: +{ mkDerivation, base, stdenv, stripe-core, stripe-http-streams, stripe-http-client }: mkDerivation { pname = "stripe-haskell"; - version = "2.3.0"; + version = "2.4.0"; src = ./.; - libraryHaskellDepends = [ base stripe-core stripe-http-streams ]; + libraryHaskellDepends = [ base stripe-core stripe-http-streams stripe-http-client ]; homepage = "https://github.com/dmjio/stripe"; description = "Stripe API for Haskell"; license = stdenv.lib.licenses.mit; diff --git a/stripe-haskell/src-http-client/Web/Stripe/Client/Stripe.hs b/stripe-haskell/src-http-client/Web/Stripe/Client/Stripe.hs new file mode 100644 index 0000000..37b2f46 --- /dev/null +++ b/stripe-haskell/src-http-client/Web/Stripe/Client/Stripe.hs @@ -0,0 +1,3 @@ +module Web.Stripe.Client.Stripe (stripe) where + +import Web.Stripe.Client.HttpClient (stripe) diff --git a/stripe-haskell/src-http-client/Web/Stripe/Client/Stripe.hs~ b/stripe-haskell/src-http-client/Web/Stripe/Client/Stripe.hs~ new file mode 100644 index 0000000..e69de29 diff --git a/stripe-haskell/stripe-haskell.cabal b/stripe-haskell/stripe-haskell.cabal index 7dc2033..90edfd4 100644 --- a/stripe-haskell/stripe-haskell.cabal +++ b/stripe-haskell/stripe-haskell.cabal @@ -1,5 +1,5 @@ name: stripe-haskell -version: 2.3.0 +version: 2.4.0 synopsis: Stripe API for Haskell license: MIT license-file: LICENSE @@ -13,18 +13,31 @@ build-type: Simple cabal-version: >=1.10 Description: For usage information please consult README.md -library - hs-source-dirs: src src-http-streams - build-depends: base >= 4 && < 5, - stripe-core, - stripe-http-streams +flag http-streams + default: False - default-language: Haskell2010 +library + build-depends: + base >= 4 && < 5, + stripe-core + default-language: + Haskell2010 exposed-modules: - Web.Stripe - Web.Stripe.Client.Stripe + Web.Stripe + Web.Stripe.Client.Stripe + ghc-options: + -Wall + if flag(http-streams) + hs-source-dirs: + src src-http-streams + build-depends: + stripe-http-streams + else + hs-source-dirs: + src src-http-client + build-depends: + stripe-http-client - ghc-options: -Wall source-repository head type: git diff --git a/stripe-http-client/default.nix b/stripe-http-client/default.nix new file mode 100644 index 0000000..99df0c1 --- /dev/null +++ b/stripe-http-client/default.nix @@ -0,0 +1,21 @@ +{ mkDerivation, aeson, base, bytestring, free, hspec, http-client +, http-client-tls, http-types, stdenv, stripe-core, stripe-tests +, text +}: +mkDerivation { + pname = "stripe-http-client"; + version = "2.4.0"; + src = ./.; + libraryHaskellDepends = [ + aeson base bytestring http-client http-client-tls http-types + stripe-core text + ]; + preCheck = '' + export STRIPEKEY="sk_test_igoYowTqR5IfovOKFKwigRmW" + ''; + testHaskellDepends = [ + base free hspec http-client stripe-core stripe-tests + ]; + description = "Stripe API for Haskell - http-client backend"; + license = stdenv.lib.licenses.mit; +} diff --git a/stripe-http-client/src/Web/Stripe/Client/HttpClient.hs b/stripe-http-client/src/Web/Stripe/Client/HttpClient.hs index 3b632c6..63723a5 100644 --- a/stripe-http-client/src/Web/Stripe/Client/HttpClient.hs +++ b/stripe-http-client/src/Web/Stripe/Client/HttpClient.hs @@ -1,4 +1,5 @@ {-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} module Web.Stripe.Client.HttpClient @@ -26,7 +27,11 @@ import qualified Network.HTTP.Types as Http import Data.Aeson as A import Data.ByteString (ByteString) import Data.Monoid ((<>)) +#if MIN_VERSION_http_client(0,5,13) +import Network.HTTP.Client as Http hiding (withManager, withConnection) +#else import Network.HTTP.Client as Http hiding (withManager) +#endif import Network.HTTP.Client.TLS as TLS import qualified Web.Stripe.StripeRequest as S diff --git a/stripe-http-client/stripe-http-client.cabal b/stripe-http-client/stripe-http-client.cabal index 20b179d..5daf437 100644 --- a/stripe-http-client/stripe-http-client.cabal +++ b/stripe-http-client/stripe-http-client.cabal @@ -1,5 +1,5 @@ name: stripe-http-client -version: 0.1 +version: 2.4.0 license: MIT license-file: LICENSE author: Christopher Reichert @@ -39,7 +39,7 @@ Test-Suite tests hs-source-dirs: tests default-language: Haskell2010 build-depends: base >= 4.7 && < 5 - , free >= 4.10 && < 4.13 + , free >= 4.10 && < 6 , hspec >= 2.1.0 && < 2.5 , stripe-core , stripe-tests diff --git a/stripe-http-client/tests/Main.hs b/stripe-http-client/tests/Main.hs index 0bb9069..f197023 100644 --- a/stripe-http-client/tests/Main.hs +++ b/stripe-http-client/tests/Main.hs @@ -1,7 +1,12 @@ +{-# LANGUAGE CPP #-} module Main where import Control.Monad.Trans.Free (FreeF(..), FreeT(..)) +#if MIN_VERSION_http_client(0,5,13) +import Network.HTTP.Client hiding (withConnection) +#else import Network.HTTP.Client +#endif import Web.Stripe.Client (StripeConfig(..), StripeError(..)) import Web.Stripe.Client.HttpClient (withConnection, callAPI) import Web.Stripe.Test.AllTests (allTests) diff --git a/stripe-http-streams/default.nix b/stripe-http-streams/default.nix index 3341896..2e64153 100644 --- a/stripe-http-streams/default.nix +++ b/stripe-http-streams/default.nix @@ -3,7 +3,7 @@ }: mkDerivation { pname = "stripe-http-streams"; - version = "2.3.0"; + version = "2.4.0"; src = ./.; libraryHaskellDepends = [ aeson base bytestring HsOpenSSL http-streams io-streams stripe-core diff --git a/stripe-http-streams/stripe-http-streams.cabal b/stripe-http-streams/stripe-http-streams.cabal index 8cb6ba8..8ad9900 100644 --- a/stripe-http-streams/stripe-http-streams.cabal +++ b/stripe-http-streams/stripe-http-streams.cabal @@ -1,5 +1,5 @@ name: stripe-http-streams -version: 2.3.0 +version: 2.4.0 license: MIT license-file: LICENSE author: David Johnson, Jeremy Shaw @@ -37,7 +37,7 @@ Test-Suite tests hs-source-dirs: tests build-depends: HsOpenSSL , base >= 4.7 && < 5 - , free >= 4.10 && < 4.13 + , free >= 4.10 && < 6 , hspec >= 2.1.0 && < 2.5 , http-streams >= 0.7 && < 0.9 , stripe-core diff --git a/stripe-tests/default.nix b/stripe-tests/default.nix index e0da3b3..9a144e8 100644 --- a/stripe-tests/default.nix +++ b/stripe-tests/default.nix @@ -4,7 +4,7 @@ }: mkDerivation { pname = "stripe-tests"; - version = "2.3.0"; + version = "2.4.0"; src = ./.; libraryHaskellDepends = [ aeson base bytestring free hspec hspec-core mtl random stripe-core diff --git a/stripe-tests/stripe-tests.cabal b/stripe-tests/stripe-tests.cabal index 7aa6dc2..755e585 100644 --- a/stripe-tests/stripe-tests.cabal +++ b/stripe-tests/stripe-tests.cabal @@ -1,5 +1,5 @@ name: stripe-tests -version: 2.3.0 +version: 2.4.0 synopsis: Tests for Stripe API bindings for Haskell license: MIT license-file: LICENSE @@ -25,7 +25,7 @@ library build-depends: aeson >= 0.8 && < 0.10 || >= 0.11 && < 1.3 , base >= 4.7 && < 5 , bytestring >= 0.10 && < 0.11 - , free >= 4.10 && < 4.13 + , free >= 4.10 && < 6 , mtl >= 2.1.2 && < 2.3 , random >= 1.1 && < 1.2 , hspec >= 2.1.0 && < 2.5