@@ -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,46 @@ 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 -> logDebug $ " No project root (.git) found at: " <> path
215+ Just gitRoot -> logInfo $ " Project root (.git) found at: " <> path <> gitRoot
216+ mSpagoYaml :: Maybe String <- map (map (\yml -> path <> yml)) $ map Array .head $ liftAff $ Glob .gitignoringGlob path [ " ./spago.yaml" ]
217+
218+ case Tuple mSpagoYaml mGitRoot of
219+ Tuple Nothing Nothing -> searchHigherPaths otherPaths
220+ Tuple Nothing (Just gitRoot) -> do
221+ -- directory containing .git assumed to be the root of the project;
222+ -- do not search up the file tree further than this
223+ logInfo $ " No Spago workspace found in any directory up to project root: " <> path <> gitRoot
224+ pure Nothing
225+ Tuple (Just spagoYaml) (Just gitRoot) -> do
226+ mWorkspace :: Maybe PrelimWorkspace <- checkForWorkspace spagoYaml
224227 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))
228+ Nothing -> do
229+ -- directory containing .git assumed to be the root of the project;
230+ -- do not search up the file tree further than this
231+ logInfo $ " No Spago workspace found in any directory up to project root: " <> path <> gitRoot
232+ pure Nothing
233+ Just ws -> pure (pure (Tuple spagoYaml ws))
234+ Tuple (Just spagoYaml) Nothing -> do
235+ mWorkspace :: Maybe PrelimWorkspace <- checkForWorkspace spagoYaml
236+ case mWorkspace of
237+ Nothing -> searchHigherPaths otherPaths
238+ Just ws -> pure (pure (Tuple spagoYaml ws))
233239
234240 -- First try to read the config in the root.
235241 -- Else, look for a workspace in parent directories.
@@ -244,7 +250,9 @@ readWorkspace { maybeSelectedPackage, pureBuild, migrateConfig } = do
244250 , toDoc " The configuration file help can be found here https://github.com/purescript/spago#the-configuration-file"
245251 ]
246252 Right config@{ yaml: { workspace: Nothing , package }, doc } -> do
247- logInfo " Looking for Spago workspace configuration higher in the filesystem, up to project root (.git)..."
253+ logInfo
254+ $ " Looking for Spago workspace configuration higher in the filesystem. Search limited to "
255+ <> show Paths .gitSearchDepth <> " levels, or project root (.git)..."
248256 mHigherWorkspace <- searchHigherPaths higherPaths
249257 case mHigherWorkspace of
250258 Nothing ->
@@ -255,15 +263,15 @@ readWorkspace { maybeSelectedPackage, pureBuild, migrateConfig } = do
255263 , " See the relevant documentation here: https://github.com/purescript/spago#the-workspace"
256264 ]
257265 Just (Tuple higherWorkspacePath higherWorkspace) -> do
258- logInfo $ " Found workspace definition in " <> higherWorkspacePath
266+ logInfo $ " Found workspace definition in: " <> higherWorkspacePath
259267 -- TODO migrate workspace at higher directory?
260268 doMigrateConfig " spago.yaml" config
261269 pure { workspace: higherWorkspace, package, workspaceDoc: doc }
262270 Right config@{ yaml: { workspace: Just workspace, package }, doc } -> do
263271 doMigrateConfig " spago.yaml" config
264272 pure { workspace, package, workspaceDoc: doc }
265273
266- logDebug " Gathering all the spago configs lower in the tree ..."
274+ logDebug " Gathering all the spago configs lower in the filesystem ..."
267275 otherLowerConfigPaths <- liftAff $ Glob .gitignoringGlob Paths .cwd [ " **/spago.yaml" ]
268276 unless (Array .null otherLowerConfigPaths) do
269277 logDebug $ [ toDoc " Found packages at these lower paths:" , Log .indent $ Log .lines (map toDoc otherLowerConfigPaths) ]
0 commit comments