Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Commit

Permalink
list-revdeps command #28
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Dec 11, 2016
1 parent bc87072 commit 80170b3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.14.5

* Add support for the `hide` field [yesodweb/wai#579](https://github.com/yesodweb/wai/issues/579)
* `list-revdeps` command [#28](https://github.com/fpco/stackage-curator/issues/28)

## 0.14.4.1

Expand Down
26 changes: 26 additions & 0 deletions Stackage/Curator/RevDeps.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
module Stackage.Curator.RevDeps
( listRevDeps
) where

import Stackage.Prelude
import Data.Yaml (decodeFileEither)
import Control.Monad.State.Strict (execState, get, put)

listRevDeps :: FilePath
-> Bool -- ^ deep revdeps
-> PackageName -- ^ package to check
-> IO ()
listRevDeps planFile deep pkg0 = do
BuildPlan {..} <- decodeFileEither planFile >>= either throwIO return
let go pkg = do
visited <- get
unless (pkg `member` visited) $ do
put $ insertSet pkg visited
case lookup pkg bpPackages of
Nothing -> return ()
Just PackagePlan {..} -> mapM_ go ppUsers
let pkgs = execState (go pkg0) (asSet mempty)
mapM_ (putStrLn . unPackageName) pkgs
12 changes: 12 additions & 0 deletions app/stackage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Options.Applicative
import Options.Applicative.Simple (simpleOptions, simpleVersion, addCommand)
import Paths_stackage_curator (version)
import Stackage.CompleteBuild
import Stackage.Curator.RevDeps
import Stackage.Curator.UploadIndex
import Stackage.DiffPlans
import Stackage.InstallBuild
Expand Down Expand Up @@ -73,6 +74,8 @@ main = do
<*> pure (T.pack "package-index/"))
addCommand "upload-docs" "Upload documentation to an S3 bucket" id
(uploadDocs' <$> target <*> bundleFile)
addCommand "list-revdeps" "List reverse dependencies" id
(listRevDeps <$> planFile <*> deepRevDeps <*> revDepPackage)

makeBundle' = makeBundle
<$> planFile
Expand Down Expand Up @@ -333,3 +336,12 @@ main = do
switch
(long "html" <> short 'h' <>
help "Wrap the output in HTML <ul>/<li> tags")

deepRevDeps =
switch
(long "deep" <>
help "List deep reverse dependencies, not just immediate users")

revDepPackage = argument packageRead
(metavar "PACKAGE-NAME" ++
help "Package to list reverse deps for")
1 change: 1 addition & 0 deletions stackage-curator.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ library
Stackage.Upload
Stackage.PerformBuild
Stackage.CompleteBuild
Stackage.Curator.RevDeps
Stackage.Curator.UploadDocs
Stackage.Curator.UploadIndex
Stackage.ShowBuildPlan
Expand Down

0 comments on commit 80170b3

Please sign in to comment.