hpack-convert 1.0.0 → 1.0.1
raw patch · 5 files changed
+75/−10 lines, 5 filesdep +splitPVP ok
version bump matches the API change (PVP)
Dependencies added: split
API changes (from Hackage documentation)
+ Hpack.Convert: ensureQuoted :: String -> String
+ Hpack.Convert: isQuoted :: String -> Bool
+ Hpack.Convert: parseCommaSep :: String -> [String]
+ Hpack.Convert: trimEnds :: String -> String
Files
- hpack-convert.cabal +6/−1
- src/Hpack/Convert.hs +35/−7
- test/data/getopt-generics.cabal.yaml +6/−2
- test/data/quoted-options.cabal +14/−0
- test/data/quoted-options.cabal.yaml +14/−0
hpack-convert.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: hpack-convert-version: 1.0.0+version: 1.0.1 synopsis: Convert Cabal manifests into hpack's package.yamls category: Development homepage: https://github.com/yamadapc/hpack-convert#readme@@ -48,6 +48,8 @@ ./test/data/hpack.cabal ./test/data/hpack.cabal.yaml ./test/data/LICENSE+ ./test/data/quoted-options.cabal+ ./test/data/quoted-options.cabal.yaml source-repository head type: git@@ -73,6 +75,7 @@ , bytestring , vector , aeson+ , split exposed-modules: Hpack.Convert other-modules:@@ -111,6 +114,7 @@ , bytestring , vector , aeson+ , split other-modules: Hpack Hpack.Config@@ -149,6 +153,7 @@ , bytestring , vector , aeson+ , split , hspec == 2.* , QuickCheck , temporary
src/Hpack/Convert.hs view
@@ -8,6 +8,7 @@ import Prelude () import Prelude.Compat +import Data.List.Split (splitOn) import Data.Maybe import qualified Data.Version as Version import qualified Distribution.Compiler as Compiler@@ -36,9 +37,9 @@ , packageBugReports = nullNothing bugReports , packageCategory = nullNothing category , packageStability = nullNothing stability- , packageAuthor = maybeToList (nullNothing author)- , packageMaintainer = maybeToList (nullNothing maintainer)- , packageCopyright = maybeToList (nullNothing copyright)+ , packageAuthor = maybe [] parseCommaSep (nullNothing author)+ , packageMaintainer = maybe [] parseCommaSep (nullNothing maintainer)+ , packageCopyright = maybe [] parseCommaSep (nullNothing copyright) , packageLicense = Just (show (Cabal.disp license)) , packageLicenseFile = listToMaybe licenseFiles , packageTestedWith =@@ -69,7 +70,7 @@ fromPackageDescriptionString :: String -> Either ConvertError Package fromPackageDescriptionString pkgStr = case Cabal.parsePackageDescription pkgStr of- Cabal.ParseFailed e -> Left (ConvertCabalParseError e)+ Cabal.ParseFailed e -> Left (ConvertCabalParseError e) Cabal.ParseOk _ gpkg -> Right (fromPackageDescription gpkg) data ConvertError = ConvertCabalParseError Cabal.PError@@ -199,8 +200,12 @@ , sectionDefaultExtensions = map (show . Cabal.disp) defaultExtensions , sectionOtherExtensions = map (show . Cabal.disp) otherExtensions- , sectionGhcOptions = fromMaybe [] $- lookup Compiler.GHC options+ , sectionGhcOptions = map (\l -> case words l of+ [] -> ""+ [x] -> x+ _ -> ensureQuoted l) $+ fromMaybe [] $+ lookup Compiler.GHC options , sectionGhcProfOptions = fromMaybe [] $ lookup Compiler.GHC profOptions , sectionCppOptions = cppOptions@@ -276,4 +281,27 @@ -- See https://github.com/sol/hpack/issues/119 processDir :: String -> String processDir "." = "./."-processDir d = d+processDir d = d++-- | Parse comma separated list, stripping whitespace+parseCommaSep :: String -> [String]+parseCommaSep s =+ -- separate on commas+ -- strip leading and trailing whitespace+ fmap trimEnds (splitOn "," s)++-- | Trim leading and trailing whitespace+trimEnds :: String -> String+trimEnds = f . f+ where f = reverse . dropWhile isSpace++ensureQuoted :: String -> String+ensureQuoted l =+ if isQuoted l+ then l+ else "\"" <> l <> "\""++isQuoted :: String -> Bool+isQuoted s = testQuote '\'' || testQuote '\"'+ where+ testQuote q = head s == q && last s == q
test/data/getopt-generics.cabal.yaml view
@@ -3,8 +3,12 @@ synopsis: Create command line interfaces with ease description: Create command line interfaces with ease category: Console, System-author: Linh Nguyen, Sönke Hahn-maintainer: linh.nguyen@zalora.com, soenkehahn@gmail.com+author:+- Linh Nguyen+- Sönke Hahn+maintainer:+- linh.nguyen@zalora.com+- soenkehahn@gmail.com copyright: Zalora South East Asia Pte Ltd license: BSD3 github: soenkehahn/getopt-generics
+ test/data/quoted-options.cabal view
@@ -0,0 +1,14 @@+name: cabal-init-minimal+version: 0.1.0.0+license: PublicDomain+author: Pedro Tacla Yamada+maintainer: tacla.yamada@gmail.com+build-type: Simple+extra-source-files: ChangeLog.md+cabal-version: >=1.10++library+ build-depends: base >=4.8 && <4.9+ hs-source-dirs: src+ default-language: Haskell2010+ ghc-options: -rtsopts "-with-rtsopts=-N15 -H4G"
+ test/data/quoted-options.cabal.yaml view
@@ -0,0 +1,14 @@+name: cabal-init-minimal+version: '0.1.0.0'+author: Pedro Tacla Yamada+maintainer: tacla.yamada@gmail.com+license: PublicDomain+extra-source-files:+- ChangeLog.md+ghc-options:+- -rtsopts+- ! '"-with-rtsopts=-N15 -H4G"'+dependencies:+- base >=4.8 && <4.9+library:+ source-dirs: src