@@ -180,7 +180,7 @@ type PrelimWorkspace =
180
180
-- | packages to be integrated in the package set
181
181
readWorkspace :: ∀ a . ReadWorkspaceOptions -> Spago (Registry.RegistryEnv a ) Workspace
182
182
readWorkspace { maybeSelectedPackage, pureBuild, migrateConfig } = do
183
- logInfo " Reading Spago workspace configuration ..."
183
+ logInfo " Reading spago.yaml ..."
184
184
185
185
let
186
186
doMigrateConfig :: FilePath -> _ -> Spago (Registry.RegistryEnv _ ) Unit
@@ -196,40 +196,46 @@ readWorkspace { maybeSelectedPackage, pureBuild, migrateConfig } = do
196
196
higherPaths :: List FilePath
197
197
higherPaths = Array .toUnfoldable $ Paths .toGitSearchPath Paths .cwd
198
198
199
- checkForWorkspace :: forall a . FilePath
200
- -> Spago (LogEnv a ) (Maybe PrelimWorkspace )
199
+ checkForWorkspace :: forall b . FilePath
200
+ -> Spago (LogEnv b ) (Maybe PrelimWorkspace )
201
201
checkForWorkspace config = do
202
- logInfo $ " Checking for workspace: " <> config
202
+ logDebug $ " Checking for workspace: " <> config
203
203
result <- map (map (\y -> y.yaml)) $ readConfig config
204
204
case result of
205
205
Left _ -> pure Nothing
206
206
Right { workspace: Nothing } -> pure Nothing
207
207
Right { workspace: Just ws } -> pure (Just ws)
208
208
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 ))
210
210
searchHigherPaths Nil = pure Nothing
211
211
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
224
227
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))
233
239
234
240
-- First try to read the config in the root.
235
241
-- Else, look for a workspace in parent directories.
@@ -244,7 +250,9 @@ readWorkspace { maybeSelectedPackage, pureBuild, migrateConfig } = do
244
250
, toDoc " The configuration file help can be found here https://github.com/purescript/spago#the-configuration-file"
245
251
]
246
252
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)..."
248
256
mHigherWorkspace <- searchHigherPaths higherPaths
249
257
case mHigherWorkspace of
250
258
Nothing ->
@@ -255,15 +263,15 @@ readWorkspace { maybeSelectedPackage, pureBuild, migrateConfig } = do
255
263
, " See the relevant documentation here: https://github.com/purescript/spago#the-workspace"
256
264
]
257
265
Just (Tuple higherWorkspacePath higherWorkspace) -> do
258
- logInfo $ " Found workspace definition in " <> higherWorkspacePath
266
+ logInfo $ " Found workspace definition in: " <> higherWorkspacePath
259
267
-- TODO migrate workspace at higher directory?
260
268
doMigrateConfig " spago.yaml" config
261
269
pure { workspace: higherWorkspace, package, workspaceDoc: doc }
262
270
Right config@{ yaml: { workspace: Just workspace, package }, doc } -> do
263
271
doMigrateConfig " spago.yaml" config
264
272
pure { workspace, package, workspaceDoc: doc }
265
273
266
- logDebug " Gathering all the spago configs lower in the tree ..."
274
+ logDebug " Gathering all the spago configs lower in the filesystem ..."
267
275
otherLowerConfigPaths <- liftAff $ Glob .gitignoringGlob Paths .cwd [ " **/spago.yaml" ]
268
276
unless (Array .null otherLowerConfigPaths) do
269
277
logDebug $ [ toDoc " Found packages at these lower paths:" , Log .indent $ Log .lines (map toDoc otherLowerConfigPaths) ]
0 commit comments