@@ -180,7 +180,7 @@ type PrelimWorkspace =
180180-- | packages to be integrated in the package set
181181readWorkspace :: ∀ a . ReadWorkspaceOptions -> Spago (Registry.RegistryEnv a ) Workspace
182182readWorkspace { maybeSelectedPackage, pureBuild, migrateConfig } = do
183- logInfo " Reading Spago workspace configuration ..."
183+ logInfo " Reading spago.yaml ..."
184184
185185 let
186186 doMigrateConfig :: FilePath -> _ -> Spago (Registry.RegistryEnv _ ) Unit
@@ -196,40 +196,50 @@ readWorkspace { maybeSelectedPackage, pureBuild, migrateConfig } = do
196196 higherPaths :: List FilePath
197197 higherPaths = Array .toUnfoldable $ Paths .toGitSearchPath Paths .cwd
198198
199- checkForWorkspace :: forall a . FilePath
200- -> Spago (LogEnv a ) (Maybe PrelimWorkspace )
199+ checkForWorkspace :: forall b . FilePath
200+ -> Spago (LogEnv b ) (Maybe PrelimWorkspace )
201201 checkForWorkspace config = do
202- logInfo $ " Checking for workspace: " <> config
202+ logDebug $ " Checking for workspace: " <> config
203203 result <- map (map (\y -> y.yaml)) $ readConfig config
204204 case result of
205205 Left _ -> pure Nothing
206206 Right { workspace: Nothing } -> pure Nothing
207207 Right { workspace: Just ws } -> pure (Just ws)
208208
209- searchHigherPaths :: forall a . List FilePath -> Spago (LogEnv a ) (Maybe (Tuple FilePath PrelimWorkspace ))
209+ searchHigherPaths :: forall c . List FilePath -> Spago (LogEnv c ) (Maybe (Tuple FilePath PrelimWorkspace ))
210210 searchHigherPaths Nil = pure Nothing
211211 searchHigherPaths (path : otherPaths) = do
212- mGitRoot :: Maybe String <- map Array .head $ liftAff $ Glob .gitignoringGlob path [ " ./.git" ]
213- mYaml :: Maybe String <- map (map (\yml -> path <> yml)) $ map Array .head $ liftAff $ Glob .gitignoringGlob path [ " ./spago.yaml" ]
214- case mYaml of
215- Nothing -> case mGitRoot of
216- Nothing -> searchHigherPaths otherPaths
217- Just gitRoot -> do
218- -- directory containing .git assumed to be the root of the project;
219- -- do not search up the file tree further than this
220- logInfo $ " No Spago workspace found in any directory up to root of project: " <> gitRoot
221- pure Nothing
222- Just foundSpagoYaml -> do
223- mWorkspace :: Maybe PrelimWorkspace <- checkForWorkspace foundSpagoYaml
212+ mGitRoot :: Maybe String <- map Array .head $ liftAff $ Glob .findGitGlob path
213+ case mGitRoot of
214+ Nothing -> do
215+ logDebug " No project root (.git) found at: "
216+ logDebug path
217+ Just gitRoot -> do
218+ logInfo " Project root (.git) found at: "
219+ logInfo $ path <> gitRoot
220+ mSpagoYaml :: Maybe String <- map (map (\yml -> path <> yml)) $ map Array .head $ liftAff $ Glob .gitignoringGlob path [ " ./spago.yaml" ]
221+
222+ case Tuple mSpagoYaml mGitRoot of
223+ Tuple Nothing Nothing -> searchHigherPaths otherPaths
224+ Tuple Nothing (Just gitRoot) -> do
225+ -- directory containing .git assumed to be the root of the project;
226+ -- do not search up the file tree further than this
227+ logInfo $ " No Spago workspace found in any directory up to project root: " <> path <> gitRoot
228+ pure Nothing
229+ Tuple (Just spagoYaml) (Just gitRoot) -> do
230+ mWorkspace :: Maybe PrelimWorkspace <- checkForWorkspace spagoYaml
224231 case mWorkspace of
225- Nothing -> case mGitRoot of
226- Nothing -> searchHigherPaths otherPaths
227- Just gitRoot -> do
228- -- directory containing .git assumed to be the root of the project;
229- -- do not search up the file tree further than this
230- logInfo $ " No Spago workspace found in any directory up to root of project: " <> gitRoot
231- pure Nothing
232- Just ws -> pure (pure (Tuple foundSpagoYaml ws))
232+ Nothing -> do
233+ -- directory containing .git assumed to be the root of the project;
234+ -- do not search up the file tree further than this
235+ logInfo $ " No Spago workspace found in any directory up to project root: " <> path <> gitRoot
236+ pure Nothing
237+ Just ws -> pure (pure (Tuple spagoYaml ws))
238+ Tuple (Just spagoYaml) Nothing -> do
239+ mWorkspace :: Maybe PrelimWorkspace <- checkForWorkspace spagoYaml
240+ case mWorkspace of
241+ Nothing -> searchHigherPaths otherPaths
242+ Just ws -> pure (pure (Tuple spagoYaml ws))
233243
234244 -- First try to read the config in the root.
235245 -- Else, look for a workspace in parent directories.
@@ -244,7 +254,8 @@ readWorkspace { maybeSelectedPackage, pureBuild, migrateConfig } = do
244254 , toDoc " The configuration file help can be found here https://github.com/purescript/spago#the-configuration-file"
245255 ]
246256 Right config@{ yaml: { workspace: Nothing , package }, doc } -> do
247- logInfo " Looking for Spago workspace configuration higher in the filesystem, up to project root (.git)..."
257+ logInfo " Looking for Spago workspace configuration higher in the filesystem."
258+ logInfo $ " Search limited to " <> show Paths .gitSearchDepth <> " levels, or project root (.git)..."
248259 mHigherWorkspace <- searchHigherPaths higherPaths
249260 case mHigherWorkspace of
250261 Nothing ->
@@ -255,15 +266,16 @@ readWorkspace { maybeSelectedPackage, pureBuild, migrateConfig } = do
255266 , " See the relevant documentation here: https://github.com/purescript/spago#the-workspace"
256267 ]
257268 Just (Tuple higherWorkspacePath higherWorkspace) -> do
258- logInfo $ " Found workspace definition in " <> higherWorkspacePath
269+ logInfo " Found workspace definition in: "
270+ logInfo higherWorkspacePath
259271 -- TODO migrate workspace at higher directory?
260272 doMigrateConfig " spago.yaml" config
261273 pure { workspace: higherWorkspace, package, workspaceDoc: doc }
262274 Right config@{ yaml: { workspace: Just workspace, package }, doc } -> do
263275 doMigrateConfig " spago.yaml" config
264276 pure { workspace, package, workspaceDoc: doc }
265277
266- logDebug " Gathering all the spago configs lower in the tree ..."
278+ logDebug " Gathering all the spago configs lower in the filesystem ..."
267279 otherLowerConfigPaths <- liftAff $ Glob .gitignoringGlob Paths .cwd [ " **/spago.yaml" ]
268280 unless (Array .null otherLowerConfigPaths) do
269281 logDebug $ [ toDoc " Found packages at these lower paths:" , Log .indent $ Log .lines (map toDoc otherLowerConfigPaths) ]
0 commit comments