@@ -14,7 +14,7 @@ module Obelisk.Command.Run where
1414import Control.Arrow ((&&&))
1515import Control.Exception (Exception, bracket)
1616import Control.Lens (ifor, (.~), (&))
17−import Control.Monad (filterM, unless)
17+import Control.Monad (filterM)
1818import Control.Monad.Except (runExceptT, throwError)
1919import Control.Monad.IO.Class (liftIO)
2020import Control.Monad.Reader (MonadIO)
@@ -160,8 +160,8 @@ profile profileBasePattern rtsFlags = withProjectRoot "." $ \root -> do
160160 ] <> rtsFlags
161161 <> [ "-RTS" ]
162162
163−run :: MonadObelisk m => Maybe FilePath -> FilePath -> PathTree Interpret -> m ()
164−run certDir root interpretPaths = do
163+run :: MonadObelisk m => FilePath -> PathTree Interpret -> m ()
164+run root interpretPaths = do
165165 pkgs <- getParsedLocalPkgs root interpretPaths
166166 assets <- findProjectAssets root
167167 putLog Debug $ "Assets impurely loaded from: " <> assets
@@ -171,7 +171,6 @@ run certDir root interpretPaths = do
171171 runGhcid root True (ghciArgs <> dotGhciArgs) pkgs $ Just $ unwords
172172 [ "Obelisk.Run.run"
173173 , show freePort
174− , "(" ++ show certDir ++ ")"
175174 , "(Obelisk.Run.runServeAsset " ++ show assets ++ ")"
176175 , "Backend.backend"
177176 , "Frontend.frontend"
@@ -305,15 +304,16 @@ parseCabalPackage
305304 -> m (Maybe CabalPackageInfo)
306305parseCabalPackage dir = parseCabalPackage' dir >>= \case
307306 Left err -> Nothing <$ putLog Error err
308− Right (warnings, pkgInfo) -> do
307+ Right (Just (warnings, pkgInfo)) -> do
309308 for_ warnings $ putLog Warning . T.pack . show
310309 pure $ Just pkgInfo
310+ Right Nothing -> pure Nothing
311311
312312-- | Like 'parseCabalPackage' but returns errors and warnings directly so as to avoid 'MonadObelisk'.
313313parseCabalPackage'
314314 :: (MonadIO m)
315315 => FilePath -- ^ Package directory
316− -> m (Either T.Text ([Dist.PWarning], CabalPackageInfo))
316+ -> m (Either T.Text (Maybe ([Dist.PWarning], CabalPackageInfo)))
317317parseCabalPackage' pkg = runExceptT $ do
318318 (cabalContents, packageFile, packageName) <- guessCabalPackageFile pkg >>= \case
319319 Left GuessPackageFileError_NotFound -> throwError $ "No .cabal or package.yaml file found in " <> T.pack pkg
@@ -341,7 +341,7 @@ parseCabalPackage' pkg = runExceptT $ do
341341 case condLibrary <$> result of
342342 Right (Just condLib) -> do
343343 let (_, lib) = simplifyCondTree evalConfVar condLib
344− pure $ (warnings,) $ CabalPackageInfo
344+ pure $ Just $ (warnings,) $ CabalPackageInfo
345345 { _cabalPackageInfo_packageName = T.pack packageName
346346 , _cabalPackageInfo_packageFile = packageFile
347347 , _cabalPackageInfo_packageRoot = takeDirectory packageFile
@@ -355,17 +355,17 @@ parseCabalPackage' pkg = runExceptT $ do
355355 , _cabalPackageInfo_compilerOptions = options $ libBuildInfo lib
356356 , _cabalPackageInfo_cppOptions = cppOptions $ libBuildInfo lib
357357 }
358− Right Nothing -> throwError "Haskell package has no library component"
358+ Right Nothing -> pure Nothing
359359 Left (_, errors) ->
360360 throwError $ T.pack $ "Failed to parse " <> packageFile <> ":\n" <> unlines (map show errors)
361361
362362parsePackagesOrFail :: (MonadObelisk m, Foldable f) => f FilePath -> m (NE.NonEmpty CabalPackageInfo)
363363parsePackagesOrFail dirs' = do
364− (pkgDirErrs, packageInfos') <- fmap partitionEithers $ for dirs $ \dir -> do
364+ packageInfos' <- fmap catMaybes $ for dirs $ \dir -> do
365365 flip fmap (parseCabalPackage dir) $ \case
366366 Just packageInfo
367− | _cabalPackageInfo_buildable packageInfo -> Right packageInfo
368− _ -> Left dir
367+ | _cabalPackageInfo_buildable packageInfo -> Just packageInfo
368+ _ -> Nothing
369369
370370 -- Sort duplicate packages such that we prefer shorter paths, but fall back to alphabetical ordering.
371371 let packagesByName = Map.map (NE.sortBy $ comparing $ \p -> let n = _cabalPackageInfo_packageFile p in (length n, n))
@@ -387,9 +387,6 @@ parsePackagesOrFail dirs' = do
387387 "No valid, buildable packages found" <> (if null dirs then "" else " in " <> intercalate ", " dirs)
388388 Just xs -> pure xs
389389
390− unless (null pkgDirErrs) $
391− putLog Warning $ T.pack $ "Failed to find buildable packages in " <> intercalate ", " pkgDirErrs
392−
393390 pure packageInfos
394391 where
395392 dirs = toList dirs'