cabal-file 0.1.0 → 0.1.1
raw patch · 7 files changed
+45/−16 lines, 7 filesdep ~CabalPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: Cabal
API changes (from Hackage documentation)
Files
- ChangeLog.md +3/−1
- README.md +17/−1
- app/Cmds.hs +5/−5
- app/Depends.hs +12/−2
- app/Main.hs +1/−1
- cabal-file.cabal +4/−3
- src/Hackage/Index.hs +3/−3
ChangeLog.md view
@@ -1,7 +1,9 @@ # Revision history for cabal-file -## 0.1.0 -- 2020-05-24+## 0.1.1 -- 2020-11-13+- diff: ignore whitespace by default +## 0.1.0 -- 2020-05-24 - initial release - cblfile commands: diff (second), list, latest, files, get, date, show, metadata, preferred, depends (oldest code)
README.md view
@@ -8,6 +8,12 @@ the local Hackage repo cache index tar archive under ~/.cabal/ it is quite fast. ## Usage+List all Hackage packages:+```+$ cblfile list | grep ghcide+ghcide+```+ List versions of a package: ``` $ cblfile list pandoc@@ -63,7 +69,17 @@ ## Library For library documentation see the [Hackage.Index](https://hackage.haskell.org/package/cabal-file/docs/Hackage-Index.html) documentation. -For example usage see `app/Cmds.hs`.+For example usage see [`app/Cmds.hs`](https://hackage.haskell.org/package/cabal-file/src/app/Cmds.hs).++## Motivation+I originally wrote the `depends` command for displaying dependency information+about packages in a more friendly way.++Later, since [hdiff](http://hdiff.luite.com/) is out of sync for some packages,+and I use it particularly for comparing versions of .cabal files,+I decided to create the `diff` command.+Realising I could pull .cabal files direct from the cabal index cache,+the rest of cabal-file flowed on from there. ## Related If you want full diffs of Hackage sources you can try out cabal-diff from
app/Cmds.hs view
@@ -13,7 +13,7 @@ import Control.Monad import Control.Monad.Extra import qualified Data.ByteString.Lazy.Char8 as BL-import Data.List+import qualified Data.List as L import Distribution.Version (Version) import SimpleCabal import SimpleCmd@@ -25,14 +25,14 @@ -- FIXME structural diff of PackageDescription -- FIXME revisions?-diffCmd :: String -> Version -> Version -> IO ()-diffCmd pkg v1 v2 =+diffCmd :: Bool -> String -> Version -> Version -> IO ()+diffCmd whitespace pkg v1 v2 = withTempDir $ \ tmpdir -> do setCurrentDirectory tmpdir let pkgid1 = PackageIdentifier (mkPackageName pkg) v1 pkgid2 = PackageIdentifier (mkPackageName pkg) v2 saveCabals pkgid1 pkgid2- void $ cmdBool "diff" ["-u", showPkgId pkgid1 <.> "cabal", showPkgId pkgid2 <.> "cabal"]+ void $ cmdBool "diff" $ ["-w" | not whitespace] ++ ["-u", showPkgId pkgid1 <.> "cabal", showPkgId pkgid2 <.> "cabal"] -- pkgdesc <- finalPackageDescription [] cabal where@@ -46,7 +46,7 @@ listPkg (Just pkgname) = do versions <- packageVersions pkgname mapM_ (putStrLn . showVersion) versions-listPkg Nothing = fmap sort listPackages >>= mapM_ putStrLn+listPkg Nothing = listPackages >>= mapM_ putStrLn . L.sort saveCabal :: PackageIdentifier -> IO () saveCabal pkgid = do
app/Depends.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+ module Depends ( Deps(..), Details(..),@@ -23,7 +25,7 @@ pkgcfgDepName, pkgconfigDepends, pkgName, setupBuildInfo, setupDependencies) -import Hackage.Index (withCabalFile)+import Hackage.Index (packageIdOrLatest, withCabalFile) data Deps = Build | Setup | Tool | Legacy | CLib | PkgConfig | NotBuild deriving (Eq, Show)@@ -49,7 +51,9 @@ else case simpleParse path of Nothing -> error $ path ++ " not a package identifier"- Just pkgid -> withCabalFile pkgid displayDepends+ Just pkgid -> do+ pkgver <- packageIdOrLatest pkgid+ withCabalFile pkgver displayDepends where displayDepends :: FilePath -> IO () displayDepends cabal = do@@ -137,3 +141,9 @@ exeDepPkgName :: ExeDependency -> PackageName exeDepPkgName (ExeDependency n _ _) = n++#if !MIN_VERSION_filepath(1,4,2)+isExtensionOf :: String -> FilePath -> Bool+isExtensionOf ext@('.':_) = isSuffixOf ext . takeExtensions+isExtensionOf ext = isSuffixOf ('.':ext) . takeExtensions+#endif
app/Main.hs view
@@ -19,7 +19,7 @@ "cabal-file can access and compare .cabal files from the cache" $ subcommands [ Subcommand "diff" "Diff .cabal files of package versions" $- diffCmd <$> strArg "PKG" <*> versionArg <*> versionArg+ diffCmd <$> switchWith 'W' "whitespace" "Show whitespace changes" <*> strArg "PKG" <*> versionArg <*> versionArg , Subcommand "list" "List package versions" $ listPkg <$> optional pkgArg , Subcommand "latest" "Latest package version" $
cabal-file.cabal view
@@ -1,5 +1,5 @@ name: cabal-file-version: 0.1.0+version: 0.1.1 synopsis: Cabal file access description: cabal-file is a small library on top of the 'hackage-security' library@@ -17,6 +17,7 @@ extra-doc-files: README.md , ChangeLog.md cabal-version: 1.18+tested-with: GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.2 source-repository head type: git@@ -29,7 +30,7 @@ hs-source-dirs: app build-depends: base < 5 , bytestring- , Cabal > 2.2+ , Cabal >= 2.2 , cabal-file , directory , extra@@ -55,7 +56,7 @@ library build-depends: base < 5 , bytestring- , Cabal > 2.2+ , Cabal >= 2.2 , directory , extra , filepath
src/Hackage/Index.hs view
@@ -23,7 +23,7 @@ ) where import qualified Data.ByteString.Lazy.Char8 as BL-import Data.List+import qualified Data.List as L import Data.Maybe import Data.Time.Clock import Data.Time.Clock.POSIX@@ -123,7 +123,7 @@ withLocalRepo $ \rep -> uncheckClientErrors $ do dir <- getDirectory rep let pkg = unPackageName pkgname- return $ sort . mapMaybe (extractPkgVersion pkg . second) $ directoryEntries dir+ return $ L.sort . mapMaybe (extractPkgVersion pkg . second) $ directoryEntries dir where second (_,b,_) = b @@ -186,7 +186,7 @@ listPackages = withLocalRepo $ \rep -> uncheckClientErrors $ do dir <- getDirectory rep- return $ nub $ mapMaybe (extractPkg . second) (directoryEntries dir)+ return $ L.nub $ mapMaybe (extractPkg . second) (directoryEntries dir) where extractPkg path = if Path.takeExtension path == ".cabal" then