hpack 0.31.1 → 0.31.2
raw patch · 6 files changed
+86/−22 lines, 6 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Hpack.Config: Path :: FilePath -> Path
+ Hpack.Config: [unPath] :: Path -> FilePath
+ Hpack.Config: instance Data.String.IsString Hpack.Config.Path
+ Hpack.Config: instance GHC.Classes.Eq Hpack.Config.Path
+ Hpack.Config: instance GHC.Classes.Ord Hpack.Config.Path
+ Hpack.Config: instance GHC.Show.Show Hpack.Config.Path
+ Hpack.Config: newtype Path
- Hpack.Config: Package :: String -> String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> [String] -> [String] -> [String] -> BuildType -> Maybe String -> [FilePath] -> Maybe String -> [Flag] -> [FilePath] -> [FilePath] -> [FilePath] -> Maybe FilePath -> Maybe SourceRepository -> Maybe CustomSetup -> Maybe (Section Library) -> Map String (Section Library) -> Map String (Section Executable) -> Map String (Section Executable) -> Map String (Section Executable) -> [Verbatim] -> Package
+ Hpack.Config: Package :: String -> String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> [String] -> [String] -> [String] -> BuildType -> Maybe String -> [FilePath] -> Maybe String -> [Flag] -> [Path] -> [Path] -> [Path] -> Maybe FilePath -> Maybe SourceRepository -> Maybe CustomSetup -> Maybe (Section Library) -> Map String (Section Library) -> Map String (Section Executable) -> Map String (Section Executable) -> Map String (Section Executable) -> [Verbatim] -> Package
- Hpack.Config: Section :: a -> [FilePath] -> Dependencies -> [String] -> [String] -> [String] -> [GhcOption] -> [GhcProfOption] -> [GhcjsOption] -> [CppOption] -> [CcOption] -> [FilePath] -> [CxxOption] -> [FilePath] -> [FilePath] -> [FilePath] -> [FilePath] -> [FilePath] -> [FilePath] -> [FilePath] -> [FilePath] -> [LdOption] -> Maybe Bool -> [Conditional (Section a)] -> Map BuildTool DependencyVersion -> SystemBuildTools -> [Verbatim] -> Section a
+ Hpack.Config: Section :: a -> [FilePath] -> Dependencies -> [String] -> [String] -> [String] -> [GhcOption] -> [GhcProfOption] -> [GhcjsOption] -> [CppOption] -> [CcOption] -> [Path] -> [CxxOption] -> [Path] -> [Path] -> [FilePath] -> [FilePath] -> [FilePath] -> [FilePath] -> [FilePath] -> [FilePath] -> [LdOption] -> Maybe Bool -> [Conditional (Section a)] -> Map BuildTool DependencyVersion -> SystemBuildTools -> [Verbatim] -> Section a
- Hpack.Config: [packageDataFiles] :: Package -> [FilePath]
+ Hpack.Config: [packageDataFiles] :: Package -> [Path]
- Hpack.Config: [packageExtraDocFiles] :: Package -> [FilePath]
+ Hpack.Config: [packageExtraDocFiles] :: Package -> [Path]
- Hpack.Config: [packageExtraSourceFiles] :: Package -> [FilePath]
+ Hpack.Config: [packageExtraSourceFiles] :: Package -> [Path]
- Hpack.Config: [sectionCSources] :: Section a -> [FilePath]
+ Hpack.Config: [sectionCSources] :: Section a -> [Path]
- Hpack.Config: [sectionCxxSources] :: Section a -> [FilePath]
+ Hpack.Config: [sectionCxxSources] :: Section a -> [Path]
- Hpack.Config: [sectionJsSources] :: Section a -> [FilePath]
+ Hpack.Config: [sectionJsSources] :: Section a -> [Path]
Files
- CHANGELOG.md +4/−0
- hpack.cabal +2/−2
- src/Hpack/Config.hs +26/−13
- src/Hpack/Render.hs +17/−6
- test/EndToEndSpec.hs +35/−0
- test/Hpack/ConfigSpec.hs +2/−1
CHANGELOG.md view
@@ -1,3 +1,7 @@+## Changes in 0.31.2+ - Add default value for maintainer (see #339)+ - Escape commas and spaces in filenames when generating cabal files+ ## Changes in 0.31.1 - Show the header when printing to stdout (see #331) - Add help for `--numeric-version`(see #337)
hpack.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: d0e64e7193dd79e7d688f56350272b988a08b6f0f9706767a37f122ceeae72ee+-- hash: 3d060180293c32b8d0c25b710d0f419e96a6cc6ec3f95ac5e70bb77f44cbafc3 name: hpack-version: 0.31.1+version: 0.31.2 synopsis: A modern format for Haskell packages description: See README at <https://github.com/sol/hpack#readme> category: Development
src/Hpack/Config.hs view
@@ -62,6 +62,7 @@ , CppOption , CcOption , LdOption+, Path(..) #ifdef TEST , renameDependencies , Empty(..)@@ -357,9 +358,9 @@ type ParseCxxSources = Maybe (List FilePath) type ParseJsSources = Maybe (List FilePath) -type CSources = [FilePath]-type CxxSources = [FilePath]-type JsSources = [FilePath]+type CSources = [Path]+type CxxSources = [Path]+type JsSources = [Path] type WithCommonOptions cSources cxxSources jsSources a = Product (CommonOptions cSources cxxSources jsSources a) a @@ -518,7 +519,7 @@ , packageConfigCategory :: Maybe String , packageConfigStability :: Maybe String , packageConfigAuthor :: Maybe (List String)-, packageConfigMaintainer :: Maybe (List String)+, packageConfigMaintainer :: Maybe (Maybe (List String)) , packageConfigCopyright :: Maybe (List String) , packageConfigBuildType :: Maybe BuildType , packageConfigLicense :: Maybe (Maybe String)@@ -829,9 +830,9 @@ , packageLicenseFile :: [FilePath] , packageTestedWith :: Maybe String , packageFlags :: [Flag]-, packageExtraSourceFiles :: [FilePath]-, packageExtraDocFiles :: [FilePath]-, packageDataFiles :: [FilePath]+, packageExtraSourceFiles :: [Path]+, packageExtraDocFiles :: [Path]+, packageDataFiles :: [Path] , packageDataDir :: Maybe FilePath , packageSourceRepository :: Maybe SourceRepository , packageCustomSetup :: Maybe CustomSetup@@ -877,10 +878,10 @@ , sectionGhcjsOptions :: [GhcjsOption] , sectionCppOptions :: [CppOption] , sectionCcOptions :: [CcOption]-, sectionCSources :: [FilePath]+, sectionCSources :: [Path] , sectionCxxOptions :: [CxxOption]-, sectionCxxSources :: [FilePath]-, sectionJsSources :: [FilePath]+, sectionCxxSources :: [Path]+, sectionJsSources :: [Path] , sectionExtraLibDirs :: [FilePath] , sectionExtraLibraries :: [FilePath] , sectionExtraFrameworksDirs :: [FilePath]@@ -1096,7 +1097,7 @@ , packageCategory = packageConfigCategory , packageStability = packageConfigStability , packageAuthor = fromMaybeList packageConfigAuthor- , packageMaintainer = fromMaybeList packageConfigMaintainer+ , packageMaintainer = fromMaybeList maintainer , packageCopyright = fromMaybeList packageConfigCopyright , packageBuildType = fromMaybe defaultBuildType packageConfigBuildType , packageLicense = join packageConfigLicense@@ -1166,6 +1167,12 @@ where fromGithub = (++ "/issues") . sourceRepositoryUrl <$> github + maintainer :: Maybe (List String)+ maintainer = case (packageConfigAuthor, packageConfigMaintainer) of+ (Just _, Nothing) -> packageConfigAuthor+ (_, Just m) -> m+ _ -> Nothing+ expandForeignSources :: MonadIO m => FilePath@@ -1179,8 +1186,14 @@ expand fieldName xs = do expandGlobs fieldName dir (fromMaybeList xs) -expandGlobs :: MonadIO m => String -> FilePath -> [String] -> Warnings m [FilePath]-expandGlobs name dir patterns = do+newtype Path = Path { unPath :: FilePath }+ deriving (Eq, Show, Ord)++instance IsString Path where+ fromString = Path++expandGlobs :: MonadIO m => String -> FilePath -> [String] -> Warnings m [Path]+expandGlobs name dir patterns = map Path <$> do (warnings, files) <- liftIO $ Util.expandGlobs name dir patterns tell warnings return files
src/Hpack/Render.hs view
@@ -66,9 +66,9 @@ packageFields :: [Element] packageFields = addVerbatim packageVerbatim . sortFieldsBy existingFieldOrder $ headerFields ++ [- Field "extra-source-files" (LineSeparatedList packageExtraSourceFiles)- , Field "extra-doc-files" (LineSeparatedList packageExtraDocFiles)- , Field "data-files" (LineSeparatedList packageDataFiles)+ Field "extra-source-files" (renderPaths packageExtraSourceFiles)+ , Field "extra-doc-files" (renderPaths packageExtraDocFiles)+ , Field "data-files" (renderPaths packageDataFiles) ] ++ maybe [] (return . Field "data-dir" . Literal) packageDataDir sourceRepository :: [Element]@@ -233,9 +233,9 @@ , renderCxxOptions sectionCxxOptions , renderDirectories "include-dirs" sectionIncludeDirs , Field "install-includes" (LineSeparatedList sectionInstallIncludes)- , Field "c-sources" (LineSeparatedList sectionCSources)- , Field "cxx-sources" (LineSeparatedList sectionCxxSources)- , Field "js-sources" (LineSeparatedList sectionJsSources)+ , Field "c-sources" (renderPaths sectionCSources)+ , Field "cxx-sources" (renderPaths sectionCxxSources)+ , Field "js-sources" (renderPaths sectionJsSources) , renderDirectories "extra-lib-dirs" sectionExtraLibDirs , Field "extra-libraries" (LineSeparatedList sectionExtraLibraries) , renderDirectories "extra-frameworks-dirs" sectionExtraFrameworksDirs@@ -395,3 +395,14 @@ renderOtherExtensions :: [String] -> Element renderOtherExtensions = Field "other-extensions" . WordList++renderPaths :: [Path] -> Value+renderPaths = LineSeparatedList . map renderPath+ where+ renderPath :: Path -> FilePath+ renderPath (Path path)+ | needsQuoting path = show path+ | otherwise = path++ needsQuoting :: FilePath -> Bool+ needsQuoting = any (\x -> isSpace x || x == ',')
test/EndToEndSpec.hs view
@@ -832,6 +832,17 @@ c-sources: foo/*.c |] `shouldWarn` pure "Specified pattern \"foo/*.c\" for c-sources does not match any files" + it "quotes filenames with special characters" $ do+ touch "cbits/foo bar.c"+ [i|+ library:+ c-sources:+ - cbits/foo bar.c+ |] `shouldRenderTo` library_ [i|+ c-sources:+ "cbits/foo bar.c"+ |]+ describe "custom-setup" $ do it "warns on unknown fields" $ do [i|@@ -1471,6 +1482,30 @@ Paths_foo default-language: Haskell2010 |]+ describe "default value of maintainer" $ do+ it "gives maintainer precedence" $ do+ [i|+ author: John Doe+ maintainer: Jane Doe+ |] `shouldRenderTo` package [i|+ author: John Doe+ maintainer: Jane Doe+ |]+ context "with author" $ do+ it "uses author if maintainer is not specified" $ do+ [i|+ author: John Doe+ |] `shouldRenderTo` package [i|+ author: John Doe+ maintainer: John Doe+ |]+ it "omits maintainer if it is null" $ do+ [i|+ author: John Doe+ maintainer: null+ |] `shouldRenderTo` package [i|+ author: John Doe+ |] run :: HasCallStack => FilePath -> FilePath -> String -> IO ([String], String) run userDataDir c old = run_ userDataDir c old >>= either assertFailure return
test/Hpack/ConfigSpec.hs view
@@ -247,7 +247,8 @@ withPackageConfig_ [i| author: John Doe |]- (`shouldBe` package {packageAuthor = ["John Doe"]})+ (`shouldBe` package {packageAuthor = ["John Doe"]+ ,packageMaintainer = ["John Doe"]}) it "accepts maintainer" $ do withPackageConfig_ [i|