packages feed

elm-get 0.1.2 → 0.1.3

raw patch · 5 files changed

+126/−52 lines, 5 filesdep +ansi-wl-pprintdep −jsondep −prettydep −resourcetdep ~Elmdep ~HTTPdep ~aesonPVP ok

version bump matches the API change (PVP)

Dependencies added: ansi-wl-pprint

Dependencies removed: json, pretty, resourcet, text

Dependency ranges changed: Elm, HTTP, aeson, aeson-pretty, binary, bytestring, containers, directory, filepath, http-client, http-client-tls, http-types, mtl, network, optparse-applicative, process, vector

API changes (from Hackage documentation)

Files

elm-get.cabal view
@@ -1,5 +1,5 @@ Name:                elm-get-Version:             0.1.2+Version:             0.1.3 Synopsis:            Tool for sharing and using Elm libraries Description:         elm-get lets you install, update, and publish Elm libraries @@ -27,33 +27,26 @@   exposed-modules:     Utils.Commands,                        Utils.Http,                        Utils.Paths-  Build-depends:       aeson,+  Build-depends:       aeson >= 0.7 && < 0.9,                        base >=4.2 && <5,-                       binary,-                       bytestring,-                       containers,-                       directory,-                       Elm >= 0.12.2,-                       filepath,-                       HTTP,-                       http-client >= 0.3,-                       http-client-tls,-                       http-types,-                       json,-                       mtl,-                       network,-                       optparse-applicative,-                       pretty,-                       process,-                       resourcet,-                       text,-                       vector+                       bytestring >= 0.9 && < 0.11,+                       directory >= 1.0 && < 2.0,+                       Elm >= 0.13 && < 0.14,+                       filepath >= 1 && < 2.0,+                       http-client >= 0.3 && < 0.4,+                       http-client-tls >= 0.2 && < 0.3,+                       http-types >= 0.7 && < 0.9,+                       mtl >= 2 && < 3,+                       network >= 2.4 && < 2.7,+                       process >= 1 && < 2,+                       vector >= 0.10 && < 0.11  Executable elm-get   ghc-options:         -threaded -O2 -W   Hs-Source-Dirs:      src   Main-is:             Get/Main.hs   other-modules:       Get.Dependencies,+                       Get.Init,                        Get.Install,                        Get.Library,                        Get.Options,@@ -62,25 +55,22 @@                        Utils.Commands,                        Utils.Http,                        Utils.Paths-  Build-depends:       aeson,-                       aeson-pretty,+  Build-depends:       aeson >= 0.7 && < 0.9,+                       aeson-pretty >= 0.7 && < 0.8,+                       ansi-wl-pprint >= 0.6 && < 0.7,                        base >=4.2 && <5,-                       binary,-                       bytestring,-                       containers,-                       directory,-                       Elm >= 0.12.2,-                       filepath,-                       HTTP,-                       http-client >= 0.3,-                       http-client-tls,-                       http-types,-                       json,-                       mtl,-                       network,-                       optparse-applicative,-                       pretty,-                       process,-                       resourcet,-                       text,-                       vector+                       binary >= 0.7 && < 0.8,+                       bytestring >= 0.9 && < 0.11,+                       containers >= 0.3 && < 0.6,+                       directory >= 1.0 && < 2.0,+                       Elm >= 0.13 && < 0.14,+                       filepath >= 1 && < 2.0,+                       HTTP >= 4000.2.5 && < 4000.3,+                       http-client >= 0.3 && < 0.4,+                       http-client-tls >= 0.2 && < 0.3,+                       http-types >= 0.7 && < 0.9,+                       mtl >= 2 && < 3,+                       network >= 2.4 && < 2.7,+                       optparse-applicative >= 0.8.1 && < 0.11,+                       process >= 1 && < 2,+                       vector >= 0.10 && < 0.11
+ src/Get/Init.hs view
@@ -0,0 +1,66 @@+module Get.Init where++import System.IO (hFlush, stdout)++import Data.Aeson.Encode.Pretty (encodePretty)+import qualified Elm.Internal.Name as N+import qualified Elm.Internal.Version as V+import qualified Elm.Internal.Dependencies as D+import qualified Elm.Internal.Paths as EPaths+import qualified Data.ByteString.Lazy as BS++askForChecked :: (String -> Either String a) -> String -> IO a+askForChecked check request = do+  putStr $ request ++ " "+  hFlush stdout+  answer <- getLine+  case check answer of+    Right result -> return result+    Left message -> do putStrLn message+                       askForChecked check request++eitherFromMaybe :: a -> Maybe b -> Either a b+eitherFromMaybe def val = case val of+  Just r -> Right r+  Nothing -> Left def++injectDefault :: Maybe [a] -> [a] -> [a]+injectDefault (Just xs) [] = xs+injectDefault _ ys = ys++askForVersion :: Maybe String -> String -> IO V.Version+askForVersion def req = askForChecked check req+  where check = (eitherFromMaybe "Wrong version format!" . V.fromString . injectDefault def)++askFor :: String -> IO String+askFor req = askForChecked Right req++askForWithDefault :: String -> String -> IO String+askForWithDefault def req = askForChecked (Right . injectDefault (Just def)) req++askForLimited :: String -> Int -> String -> IO String+askForLimited name limit req = askForChecked check req+  where check str = if length str > limit+                    then Left errorMessage+                    else Right str+        errorMessage = concat [ name+                              , " length shouldn't exceed "+                              , show limit+                              , " characters!"]++readDeps :: IO D.Deps+readDeps = do+  projectName <- askFor "Project name:"+  userName <- askFor "Github user name:"+  version <- askForVersion (Just "0.1.0") "Initial version? [default: 0.1.0]"+  summary <- askForLimited "Summary" 80 "Summary:"+  description <- askFor "Description:"+  license <- askForWithDefault "BSD3" "License? [default: BSD3]"+  repo <- askFor "Repository address?"+  elmVersion <- askForVersion Nothing "Elm version?"+  return $ D.Deps (N.Name userName projectName) version summary description license repo [] [] elmVersion []++initialize :: IO ()+initialize = do+  dependencies <- readDeps+  BS.writeFile EPaths.dependencyFile (encodePretty dependencies)
src/Get/Install.hs view
@@ -146,7 +146,7 @@   do let directory = N.toFilePath . Lib.lib $ l      exists  <- liftIO $ doesDirectoryExist directory      (if exists then update else clone) (Lib.lib l) directory-     version <- getVersion l+     version <- getVersion directory l      Cmd.inDir directory (checkout version)      return (directory, version)   where@@ -170,8 +170,8 @@ version number is requested, use the latest tagless version number in the registry. If the repo is not in the registry, warn the user and check on github. -}-getVersion :: Library -> ErrorT String IO V.Version-getVersion (Lib.Library name mayVsn) =+getVersion :: FilePath -> Library -> ErrorT String IO V.Version+getVersion dir (Lib.Library name mayVsn) =   do versions <- getVersions name      case mayVsn of        Nothing ->@@ -189,7 +189,8 @@            Just vs -> return vs            Nothing ->              do Cmd.out $ "Warning: library " ++ show name ++ " is not registered publicly. Checking github..."-                tags <- lines <$> Cmd.git [ "tag", "--list" ]+                tags <- lines <$> (Cmd.inDir dir . Cmd.git $ [ "tag", "--list" ])+                Cmd.out $ unlines tags                 return $ Maybe.mapMaybe V.fromString tags      errorNoTags =
src/Get/Main.hs view
@@ -15,6 +15,7 @@ import Get.Options as Options import qualified Get.Publish as Publish import qualified Utils.Commands as Cmd+import qualified Get.Init as Init  main :: IO () main = do@@ -41,6 +42,8 @@           Install.install vsndL      Publish -> Publish.publish++    Init -> lift Init.initialize      Update _ -> Cmd.out "Not implemented yet!"   where
src/Get/Options.hs view
@@ -5,6 +5,7 @@ import Data.Monoid import Data.Version (showVersion) import Options.Applicative as Opt+import Text.PrettyPrint.ANSI.Leijen (text, vcat, Doc)  import Get.Library import qualified Paths_elm_get as This@@ -13,6 +14,7 @@     = Install (Maybe RawLibrary)     | Update  { libs :: [String] }     | Publish+    | Init     deriving (Show, Eq)  parse :: IO Command@@ -20,6 +22,9 @@   where     prefs = Opt.prefs $ mempty <> showHelpOnError +linesDoc :: [String] -> Doc+linesDoc = vcat . map text+ parser :: ParserInfo Command parser = info (helper <*> commands) infoMod   where@@ -27,7 +32,7 @@         [ fullDesc         , header top         , progDesc "install and publish elm libraries"-        , footer moreHelp+        , footerDoc (Just moreHelp)         ]      top = unwords@@ -35,7 +40,7 @@         , "The Elm Package Manager (c) Evan Czaplicki 2013-2014\n"         ] -    moreHelp = unlines+    moreHelp = linesDoc         [ "To learn more about a command called COMMAND, just do:"         , "  elm-get COMMAND --help"         ]@@ -46,6 +51,7 @@     [ command "install" installOpts     , command "publish" publishOpts --    , command "update"  updateOpts -- TODO: implement update+    , command "init" initOpts     ]  installOpts :: ParserInfo Command@@ -54,16 +60,24 @@     infoMod = mconcat         [ fullDesc         , progDesc "Install libraries in the local project."-        , footer examples+        , footerDoc (Just examples)         ] -    examples = unlines+    examples = linesDoc         [ "Examples:"         , "  elm-get install                # install everything needed by elm_dependencies.json"         , "  elm-get install tom/Array      # install a specific github repo"         , "  elm-get install tom/Array 1.2  # install a specific version tag github repo"         ] +initOpts :: ParserInfo Command+initOpts = info (pure Init) infoMod+  where+    infoMod = mconcat+        [ fullDesc+        , progDesc "Initialize elm_dependencies.json in working directory"+        ]+ library :: Parser RawLibrary library = Library <$> lib <*> optional ver   where@@ -79,9 +93,9 @@ --   (Update <$> many (argument str (metavar "LIBRARY" <> help "Library to update"))) --   ( fullDesc --   <> progDesc "Check for updates to any local libraries, ask to upgrade."---   <> footer   examples+--   <> footerDoc   examples --   )---   where examples = unlines+--   where examples = linesDoc --           [ "Examples:" --           , "  elm-get update             # check for updates to local libraries" --           , "  elm-get update tom/Array   # update from a specific github repo" ]