on master help sign in
Merge remote-tracking branch 'origin/develop' into add-obelisk-profiling-feature
commit6acacc7fe34fe3441c860d10a7defa0b08a63d47 authorMatthew Bauer <mjbauer95@gmail.com> dateWed 12 Feb 2020, 13:38 (7 years ago) parent30183edfb0c347
3 files changed+20−7
ChangeLog.md+2 lib/command/src/Obelisk/Command/Project.hs+5−5 lib/command/src/Obelisk/Command/Run.hs+13−2
ChangeLog.md+2
@@ -5,6 +5,8 @@ This project's release branch is `master`. This log is written from the perspect
55## Unreleased
66
77* Fix a bug in `Obelisk.Route.Frontend` where `routeLink`, `routeLinkDynAttr`, and `dynRouteLink` would not behave exactly like `<a href="...">` when run by JavaScript. These functions now scroll to the top of the page when the link is clicked. ([#540](https://github.com/obsidiansystems/obelisk/pull/540))
8+* Fix a bug in `ob run`/`ob watch`/`ob repl` where nested Obelisk projects would also be loaded into the session. These are now ignored. ([#652](https://github.com/obsidiansystems/obelisk/pull/652))
9+* Improve behavior of `ob run`/`ob watch`/`ob repl` when multiple packages with the same name are encountered. Obelisk now issues a warning and tells you which one it will use. ([#653](https://github.com/obsidiansystems/obelisk/pull/653))
810
911## v0.5.0.0 - 2020-02-07
1012
lib/command/src/Obelisk/Command/Project.hs+5−5
@@ -187,7 +187,7 @@ findProjectRoot target = do
187187 targetStat <- liftIO $ getFileStatus target
188188 umask <- liftIO getUmask
189189 (result, _) <- liftIO $ runStateT (walkToProjectRoot target targetStat umask myUid) []
190− return result
190+ return $ makeRelative "." <$> result
191191
192192withProjectRoot :: MonadObelisk m => FilePath -> (FilePath -> m a) -> m a
193193withProjectRoot target f = findProjectRoot target >>= \case
@@ -321,10 +321,10 @@ findProjectAssets root = do
321321 ]
322322 -- Check whether the impure static files are a derivation (and so must be built)
323323 if isDerivation == "1"
324− then fmap T.strip $ readProcessAndLogStderr Debug $ -- Strip whitespace here because nix-build has no --raw option
325− setCwd (Just root) $ proc nixBuildExePath
324+ then fmap T.strip $ readProcessAndLogStderr Debug $ setCwd (Just root) $ -- Strip whitespace here because nix-build has no --raw option
325+ proc nixBuildExePath
326326 [ "--no-out-link"
327327 , "-E", "(import ./. {}).passthru.staticFilesImpure"
328328 ]
329− else readProcessAndLogStderr Debug $
330− proc nixExePath ["eval", "-f", root, "passthru.staticFilesImpure", "--raw"]
329+ else readProcessAndLogStderr Debug $ setCwd (Just root) $
330+ proc nixExePath ["eval", "-f", ".", "passthru.staticFilesImpure", "--raw"]
lib/command/src/Obelisk/Command/Run.hs+13−2
@@ -9,6 +9,7 @@ module Obelisk.Command.Run where
99import Control.Arrow ((&&&))
1010import Control.Exception (Exception, bracket)
1111import qualified Control.Lens as Lens
12+import Control.Lens (ifor)
1213import Control.Monad (filterM, unless)
1314import Control.Monad.Except (runExceptT, throwError)
1415import Control.Monad.IO.Class (liftIO)
@@ -159,7 +160,7 @@ getLocalPkgs root = do
159160 -- We do not want to find packages that are embedded inside other obelisk projects, unless that
160161 -- obelisk project is our own.
161162 let exclusions = filter (/= root) $ map takeDirectory obeliskPaths
162− runFind $
163+ fmap (map (makeRelative ".")) $ runFind $
163164 ["-L", root, "(", "-name", "*.cabal", "-o", "-name", Hpack.packageConfig, ")", "-a", "-type", "f"]
164165 <> concat [["-not", "-path", p </> "*"] | p <- exclusions]
165166 where
@@ -276,7 +277,17 @@ parsePackagesOrFail dirs = do
276277 | _cabalPackageInfo_buildable packageInfo -> Right packageInfo
277278 _ -> Left dir
278279
279− packageInfos <- case NE.nonEmpty packageInfos' of
280+ let packagesByName = Map.fromListWith (<>) [(_cabalPackageInfo_packageName p, p NE.:| []) | p <- packageInfos']
281+ unambiguous <- ifor packagesByName $ \packageName ps -> case ps of
282+ p NE.:| [] -> pure p -- No ambiguity here
283+ p NE.:| _ -> do
284+ putLog Warning $ T.pack $
285+ "Packages named '" <> T.unpack packageName <> "' appear in " <> show (length ps) <> " different locations: "
286+ <> intercalate ", " (map _cabalPackageInfo_packageFile $ toList ps)
287+ <> "; Picking " <> _cabalPackageInfo_packageFile p
288+ pure p
289+
290+ packageInfos <- case NE.nonEmpty $ toList unambiguous of
280291 Nothing -> failWith $ T.pack $ "No valid, buildable packages found in " <> intercalate ", " dirs
281292 Just xs -> pure xs
282293