hwm 0.0.1 → 0.0.5
raw patch · 6 files changed
+22/−11 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ HWM.Core.Pkg: cabalFilePath :: Pkg -> FilePath
+ HWM.Core.Result: maxSeverity :: [Issue] -> Maybe Severity
Files
- hwm.cabal +2/−2
- src/HWM/CLI/Command/Publish.hs +2/−2
- src/HWM/Core/Pkg.hs +4/−0
- src/HWM/Core/Result.hs +6/−3
- src/HWM/Integrations/Toolchain/Cabal.hs +6/−4
- src/HWM/Runtime/Logging.hs +2/−0
hwm.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.38.1.+-- This file has been generated from package.yaml by hpack version 0.36.0. -- -- see: https://github.com/sol/hpack name: hwm-version: 0.0.1+version: 0.0.5 synopsis: Haskell Workspace Manager - Orchestrates Stack, Cabal, and HLS description: HWM (Haskell Workspace Manager) manages multi-package Haskell projects by generating and synchronizing configuration files for Stack, Cabal, Hpack, and HLS
src/HWM/CLI/Command/Publish.hs view
@@ -17,7 +17,7 @@ statusIcon, ) import HWM.Core.Pkg (Pkg (..))-import HWM.Core.Result (Issue)+import HWM.Core.Result (Issue, Severity (..), maxSeverity) import HWM.Domain.ConfigT (ConfigT, askVersion, askWorkspaceGroups) import HWM.Domain.Workspace (WorkspaceGroup, canPublish, memberPkgs, pkgGroupName, selectGroup) import HWM.Integrations.Toolchain.Stack (sdist, upload)@@ -28,7 +28,7 @@ failIssues [] = pure () failIssues issues = do printSummary issues- liftIO exitFailure+ when (maxSeverity issues == Just SeverityError) $ liftIO exitFailure collectGroups :: Maybe Name -> [WorkspaceGroup] -> ConfigT [WorkspaceGroup] collectGroups Nothing ws = pure $ filter canPublish ws
src/HWM/Core/Pkg.hs view
@@ -16,6 +16,7 @@ pkgYamlPath, pkgId, scanPkgs,+ cabalFilePath, ) where @@ -66,6 +67,9 @@ pkgFile :: Pkg -> FilePath -> FilePath pkgFile Pkg {..} file = normalise $ joinPath [pkgDirPath, file]++cabalFilePath :: Pkg -> FilePath+cabalFilePath Pkg {..} = normalise $ joinPath [pkgDirPath, toString pkgName <> ".cabal"] pkgId :: Pkg -> Text pkgId Pkg {pkgGroup, pkgMemberId} = pkgGroup <> "/" <> pkgMemberId
src/HWM/Core/Result.hs view
@@ -16,6 +16,7 @@ Severity (..), IssueDetails (..), fromEither,+ maxSeverity, ) where @@ -63,11 +64,13 @@ catchIssues :: m a -> m (Maybe Severity, a) mapIssue :: (Issue -> Issue) -> m a -> m a +maxSeverity :: [Issue] -> Maybe Severity+maxSeverity [] = Nothing+maxSeverity issues_ = Just $ maximum $ map issueSeverity issues_+ instance MonadIssue (Result Issue) where injectIssue issue = Success () [issue]- catchIssues m@(Success _ ls) = do- let l = if null ls then Nothing else Just (maximum $ map issueSeverity ls)- in (l,) <$> m+ catchIssues m@(Success _ ls) = (maxSeverity ls,) <$> m catchIssues m@Failure {} = (Just SeverityError,) <$> m mapIssue f (Success x ls) = Success x (map f ls) mapIssue f (Failure e) = Failure (f <$> e)
src/HWM/Integrations/Toolchain/Cabal.hs view
@@ -13,9 +13,10 @@ import Distribution.Simple.PackageDescription (readGenericPackageDescription) import Distribution.Verbosity (normal) import HWM.Core.Formatting (Status (..))-import HWM.Core.Pkg (Pkg (..), pkgYamlPath)+import HWM.Core.Pkg (Pkg (..), cabalFilePath, pkgYamlPath) import HWM.Core.Result (Issue (..), IssueDetails (..), MonadIssue (..), Severity (..)) import HWM.Domain.ConfigT (ConfigT)+import HWM.Runtime.Files (remove) import Hpack (Result (..), defaultOptions, hpackResult, setProgramName, setTarget) import qualified Hpack as H import Hpack.Config (ProgramName (..))@@ -35,8 +36,8 @@ isError PackageDistSuspicious {} = False validateHackage :: Pkg -> FilePath -> ConfigT [Status]-validateHackage pkg cabalFilePath = do- gpd <- liftIO $ readGenericPackageDescription normal cabalFilePath+validateHackage pkg path = do+ gpd <- liftIO $ readGenericPackageDescription normal path let ls = checkPackage gpd Nothing for_ ls $ \l -> do injectIssue@@ -44,13 +45,14 @@ { issueMessage = "Invalid package: " <> show l, issueSeverity = if isError l then SeverityError else SeverityWarning, issueTopic = pkgMemberId pkg,- issueDetails = Just GenericIssue {issueFile = cabalFilePath}+ issueDetails = Just GenericIssue {issueFile = path} } ) pure (map toStatus ls) syncCabal :: Pkg -> ConfigT Status syncCabal pkg = do+ remove (cabalFilePath pkg) let programName = ProgramName $ toString $ pkgName pkg let ops = setTarget (pkgYamlPath pkg) $ setProgramName programName defaultOptions Result {..} <- liftIO $ hpackResult ops
src/HWM/Runtime/Logging.hs view
@@ -13,6 +13,7 @@ import Data.Time (getCurrentTime) import HWM.Core.Common (Name) import Relude+import System.Directory (createDirectoryIfMissing) import qualified System.IO as TIO logRoot :: FilePath@@ -26,6 +27,7 @@ timestamp <- liftIO getCurrentTime let logInfo = [("TIMESTAMP", show timestamp)] let path = logPath name+ liftIO $ createDirectoryIfMissing True logRoot let boxTop = "┌──────────────────────────────────────────────────────────" boxBottom = "└──────────────────────────────────────────────────────────" rows = map (\(k, v) -> "│ " <> k <> ": " <> v) (table <> logInfo)