packages feed

neil 0.8 → 0.9

raw patch · 5 files changed

+63/−34 lines, 5 files

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) Neil Mitchell 2010-2014+Copyright (c) Neil Mitchell 2010-2015 All rights reserved.  Redistribution and use in source and binary forms, with or without
+ README.md view
@@ -0,0 +1,5 @@+# Neil: Workflow Utilities [![Hackage version](https://img.shields.io/hackage/v/neil.svg?style=flat)](https://hackage.haskell.org/package/neil) [![Build Status](https://img.shields.io/travis/ndmitchell/neil.svg?style=flat)](https://travis-ci.org/ndmitchell/neil)++A tool for performing common actions run by Neil Mitchell. Many of these commands enhance specific aspects of my workflow. While other people are welcome to use this tool, it is not supported. Use `neil --help` to see what is available. Some uses:++* `neil docs` can be used to upload documentation to Hackage, as per [this blog post](http://neilmitchell.blogspot.com/2014/10/fixing-haddock-docs-on-hackage.html).
neil.cabal view
@@ -1,22 +1,23 @@ cabal-version:      >= 1.6 build-type:         Simple name:               neil-version:            0.8+version:            0.9 license:            BSD3 license-file:       LICENSE category:           Development author:             Neil Mitchell <ndmitchell@gmail.com> maintainer:         Neil Mitchell <ndmitchell@gmail.com>-copyright:          Neil Mitchell 2010-2014+copyright:          Neil Mitchell 2010-2015 synopsis:           General tools for Neil description:     General tools for Neil. Typically, I don't bother releasing these tools, and just leave     them in the Git repo. homepage:           http://community.haskell.org/~ndm/ bug-reports:        https://github.com/ndmitchell/neil/issues-tested-with:        GHC==7.8.3, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2+tested-with:        GHC==7.10.1, GHC==7.8.3, GHC==7.6.3, GHC==7.4.2, GHC==7.2.2 extra-source-files:     CHANGES.txt+    README.md  source-repository head     type:     git
src/Arguments.hs view
@@ -7,8 +7,8 @@  data Arguments     -- darcs stuff-    = Whatsnew {repo :: FilePath, delete_locks :: Bool, local :: Bool, look_for_adds :: Bool, ssh :: Bool}-    | Pull {repo :: FilePath, delete_locks :: Bool}+    = Whatsnew {repo :: FilePath, local :: Bool, look_for_adds :: Bool, ssh :: Bool}+    | Pull {repo :: FilePath}     | Push {repo :: FilePath, ssh :: Bool}     | Send {repo :: FilePath, patch :: FilePath}     | Apply {patch :: FilePath}@@ -20,12 +20,11 @@     -- cabal stuff     | Sdist     | Check-    | Test {install :: Bool}+    | Test {install :: Bool, no_warnings :: Bool}       deriving (Data,Typeable,Show)  arguments = cmdArgsMode $ modes     [Whatsnew {repo = "." &= typDir &= help "Repo to use"-              ,delete_locks = False &= help "Delete lock files"               ,local = False &= help "Only check for local changes, no network required"               ,look_for_adds = False &= name "l" &= help "Look for files to add"               ,ssh = False &= help "SSH connections only, for if the http is down"}@@ -44,6 +43,6 @@     ,Check     ,Docs {username = "NeilMitchell", host = "https://hackage.haskell.org"}     ,Travis {wait = 0 &= help "Time to wait after each wget request"}-    ,Test {install = False &= help "Install after building"}+    ,Test {install = False &= help "Install after building", no_warnings = False}     ]     &= summary "Neil's utility tool"
src/Cabal.hs view
@@ -13,7 +13,7 @@ import System.Process.Extra import Arguments -defAllow = ["7.0.4","7.2.2","7.4.2","7.6.3","7.8.2","7.8.3"]+defAllow = ["7.2.2","7.4.2","7.6.3","7.8.3","7.10.1"]   ---------------------------------------------------------------------@@ -34,11 +34,37 @@      checkCabalFile     checkReadme-    let require = ":set -fwarn-unused-binds -fwarn-unused-imports"+    checkGhci+    checkTravis+++checkGhci :: IO ()+checkGhci = do     src <- readFile' ".ghci"-    when (require `notElem` lines src) $-        error $ "The .ghci file does not contain " ++ require+    let require = words "-fwarn-unused-binds -fwarn-unused-imports"+    let missing = require \\ words src+    when (missing /= []) $+        error $ "The .ghci file does not contain " ++ unwords missing ++checkTravis :: IO ()+checkTravis = do+    tests <- testedWith+    let require =+            ["env:"] +++            [" - GHCVER=" ++ t | t <- reverse tests] +++            [" - GHCVER=head"+            ,"script:"+            ," - wget https://raw.github.com/ndmitchell/neil/master/travis.sh -O - --no-check-certificate --quiet | sh"+            ]+    src <- readFile' ".travis.yml"+    let got = filter (not . null) $ map (trimEnd . takeWhile (/= '#')) $ lines src+    when (got /= require) $+        error $ unlines $+            [".travis.yml file mismatch","Wanted:"] ++ require +++            ["Got:"] ++ got++ -- | Run some commands in a temporary directory with the unpacked cabal withSDist :: IO a -> IO a withSDist run = withTempDir $ \tdir -> do@@ -65,7 +91,7 @@         system_ $ "cabal configure --enable-tests --disable-library-profiling " ++               "--ghc-option=-fwarn-unused-binds --ghc-option=-fwarn-unused-imports " ++               "--ghc-option=-fwarn-tabs " ++-              "--ghc-option=-Werror"+              (if no_warnings then "" else "--ghc-option=-Werror")         system_ "cabal build"         system_ "cabal test --show-details=always"         when install $@@ -73,24 +99,17 @@  run Check = Just cabalCheck -run Sdist{..} = Just $ do+run Sdist = Just $ do     cabalCheck     tested <- testedWith     withSDist $ do-        forM_ (sort tested) $ \x -> do -- deliberately start with the oldest first-            putStrLn $ "Building with " ++ x-            system_ "cabal clean"-            system_ $ "cabal install --only-dependencies " ++-                  "--with-compiler=c:\\ghc\\ghc-" ++ x ++ "\\bin\\ghc.exe --with-haddock=c:\\ghc\\ghc-" ++ x ++ "\\bin\\haddock.exe " ++-                  "--with-hc-pkg=c:\\ghc\\ghc-" ++ x ++ "\\bin\\ghc-pkg.exe " ++-                  "--flags=testprog"-            system_ $ "cabal configure --ghc-option=-fwarn-unused-imports --disable-library-profiling " +++        system_ "cabal clean"+        system_ "cabal install --only-dependencies"+        system_ $ "cabal configure --ghc-option=-fwarn-unused-imports --disable-library-profiling " ++                   "--ghc-option=-Werror --ghc-option=-fno-warn-warnings-deprecations " ++ -- CABAL BUG WORKAROUND :(-                  "--with-compiler=c:\\ghc\\ghc-" ++ x ++ "\\bin\\ghc.exe --with-haddock=c:\\ghc\\ghc-" ++ x ++ "\\bin\\haddock.exe " ++-                  "--with-hc-pkg=c:\\ghc\\ghc-" ++ x ++ "\\bin\\ghc-pkg.exe " ++                   "--flags=testprog"-            system_ "cabal build"-            system_ "cabal haddock --executables"+        system_ "cabal build"+        system_ "cabal haddock"     system_ "cabal sdist"     putStrLn $ "Ready to release! (remember to neil tag after uploading)" @@ -104,6 +123,7 @@         system_ $ "cp -R dist/doc/html/" ++ name ++ " \"" ++ dir ++ "/" ++ name ++ "-" ++ ver ++ "-docs\""         files <- listFilesRecursive dir         forM_ files $ \file -> when (takeExtension file == ".html") $ do+            system_ $ "chmod u+w " ++ (dir </> file)             src <- readFileBinary' $ dir </> file             src <- return $ filter (/= '\r') src -- filter out \r, due to CPP bugs             src <- return $ fixFileLinks $ fixHashT src@@ -150,8 +170,8 @@     project <- takeBaseName . fromMaybe (error "Couldn't find cabal file") <$> findCabal     let want =             "[![Hackage version](https://img.shields.io/hackage/v/" ++ project ++ ".svg?style=flat)]" ++-            "(http://hackage.haskell.org/package/" ++ project ++ ") " ++-            "[![Build Status](http://img.shields.io/travis/" ++ qualify project ++ ".svg?style=flat)]" +++            "(https://hackage.haskell.org/package/" ++ project ++ ") " +++            "[![Build Status](https://img.shields.io/travis/" ++ qualify project ++ ".svg?style=flat)]" ++             "(https://travis-ci.org/" ++ qualify project ++ ")"     src <- readFile "README.md"     let line1 = head $ lines src ++ [""]@@ -171,17 +191,21 @@                 | (x,':':_) <- map (break (== ':') . trimStart) src                 , not $ any isSpace $ trim x, not $ "http" `isSuffixOf` x || "https" `isSuffixOf` x                 , not $ all (\x -> isLower x || x == '-') x] ++-            ["2014 is not in the copyright year" | not $ "2014" `isInfixOf` concat (grab "copyright")] ++-            ["copyright string is not at the start of the license" | not $ concat (grab "copyright") `isInfixOf` concat (take 1 $ lines license)] +++            ["2015 is not in the copyright year" | not $ "2015" `isInfixOf` concat (grab "copyright")] +++            ["copyright string is not at the start of the license" | not $ (concat (grab "copyright") `isInfixOf` concat (take 1 $ lines license)) || grab "license" == ["GPL"]] ++             ["No correct source-repository link"                 | let want = "source-repository head type: git location: https://github.com/" ++ qualify project ++ ".git"                 , not $ want `isInfixOf` unwords (words $ unlines src)] ++             ["No bug-reports link" | grab "bug-reports" /= ["https://github.com/" ++ qualify project ++ "/issues"]] ++-            ["Incorrect license " | grab "license" `notElem` [["BSD3"],["MIT"]]] ++-            ["Invalid tested-with: " ++ show test | length test < 1 || not (null $ test \\ defAllow) || test /= reverse (sort test) || (not (test `isPrefixOf` reverse defAllow) && False)] +++            ["Incorrect license " | grab "license" `notElem` [["BSD3"],["MIT"],["GPL"]]] +++            ["Invalid tested-with: " ++ show test | not $ validTests test] ++             ["Bad stabilty, should be missing" | grab "stability" /= []] ++-            ["Missing CHANGES.txt in extra-source-files" | ["CHANGES.txt","changelog.md"] `disjoint` concatMap words (grab "extra-source-files")]+            ["Missing CHANGES.txt in extra-source-files" | ["CHANGES.txt","changelog.md"] `disjoint` concatMap words (grab "extra-source-files")] +++            ["Missing README.md in extra-source-files" | "README.md" `notElem` concatMap words (grab "extra-source-files")]     unless (null bad) $ error $ unlines bad++validTests :: [String] -> Bool+validTests xs = length xs > 1 && xs `isPrefixOf` reverse defAllow  qualify :: String -> String qualify "filepath" = "haskell/filepath"