Skip to content

Commit 8cc4323

Browse files
authored
Merge branch 'master' into npm-link
2 parents 6adb1f0 + 81f5ceb commit 8cc4323

File tree

78 files changed

+951
-487
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+951
-487
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,18 @@ Other improvements:
4343
- When the `publish.location` field is missing, `spago publish` will attempt to
4444
figure out the location from Git remotes and write it back to `spago.yaml`.
4545
- Internally Spago uses stricter-typed file paths.
46+
- Spago can now be launched from a directory nested within the workspace, not
47+
just from workspace root.
4648
- `spago install` warns the user when the installed versions of packages are outside
4749
their specified dependency ranges.
4850
- `spago publish` no longer tries to validate all workspace dependencies, but
4951
only the (transitive) dependencies of the project being published.
50-
- Restored broken search-directed search in generated docs.
52+
- Restored broken type-directed search in generated docs.
53+
- `spago graph modules` now correctly reports extra-packages located outside the
54+
workspace root.
55+
- on `spago publish` - add support for urls without `.git` suffix.
56+
Before: `ssh://git@github.com/foo/bar.git` - ok, `ssh://git@github.com/foo/bar` - error
57+
After: `ssh://git@github.com/foo/bar.git` - ok, `ssh://git@github.com/foo/bar` - ok
5158

5259
## [0.21.0] - 2023-05-04
5360

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ In this case we override the package with its local copy, which should have a `s
506506

507507
```yaml
508508
workspace:
509+
packageSet:
509510
registry: 41.2.0
510511
extraPackages:
511512
aff:
@@ -538,6 +539,7 @@ In this case, we can just change the override to point to some commit of our for
538539

539540
```yaml
540541
workspace:
542+
packageSet:
541543
registry: 41.2.0
542544
extraPackages:
543545
aff:
@@ -560,7 +562,8 @@ There are a few possible scenarios - the most straightforward is when a package
560562

561563
```
562564
workspace:
563-
registry: 41.2.0
565+
packageSet:
566+
registry: 41.2.0
564567
extraPackages:
565568
some-package-from-the-registry: 4.0.0
566569
```
@@ -569,6 +572,7 @@ Another possibility is that the package is not in the registry (maybe it's your
569572

570573
```yaml
571574
workspace:
575+
packageSet:
572576
registry: 41.2.0
573577
extraPackages:
574578
facebook:
@@ -584,6 +588,7 @@ The last possible case is the one picking up a local folder as a package (note:
584588

585589
```yaml
586590
workspace:
591+
packageSet:
587592
registry: 41.2.0
588593
extraPackages:
589594
facebook:
@@ -831,6 +836,9 @@ The `--package` flag is also available for many more commands, such as `build`,
831836

832837
An important property of this "monorepo setup" is that the `output` folder will be shared between all the packages: they will share the same build package set (or build plan when using the solver) and they will be all build together.
833838

839+
> [!NOTE]\
840+
> Remember that you can't have multiple modules with the same name in a single project. This usually happens with the `Main` module being defined multiple times. Rename these modules to something unique.
841+
834842
### Polyrepo support
835843

836844
There might be cases where you want to have multiple loosely-connected codebases in the same repository that do _not_ necessarily build together all the time. This is sometimes called [a "polyrepo"][monorepo-tools].
@@ -1617,9 +1625,9 @@ packages, you should run the appropriate package-manager for that (e.g. npm).
16171625

16181626
Spago dropped support for the --watch flag in `spago build` and `spago test`.
16191627

1620-
VSCode users are recommended to use the [Purescript IDE](purescript-ide) extension for seamless experiences with automatic rebuilds.
1628+
VSCode users are recommended to use the [Purescript IDE][ide-purescript] extension for seamless experiences with automatic rebuilds.
16211629

1622-
Users of other editors, e.g. vim, emacs, etc., can make use of the underlying [LSP plugin](purescript-language-server).
1630+
Users of other editors, e.g. vim, emacs, etc., can make use of the underlying [LSP plugin][purescript-language-server].
16231631

16241632
If you want a very simple drop in replacement for `spago test --watch`, you can use a general purpose tool such as [watchexec]:
16251633

@@ -1656,6 +1664,6 @@ and similarly for the `test` folder, using that for the test sources.
16561664
[purescript-overlay]: https://github.com/thomashoneyman/purescript-overlay
16571665
[sample-package-set]: https://github.com/purescript/registry/blob/main/package-sets/41.2.0.json
16581666
[watchexec]: https://github.com/watchexec/watchexec#quick-start
1659-
[purescript-langugage-server]: https://github.com/nwolverson/purescript-language-server
1667+
[purescript-language-server]: https://github.com/nwolverson/purescript-language-server
16601668
[ide-purescript]: https://marketplace.visualstudio.com/items?itemName=nwolverson.ide-purescript
16611669
[registry-dev-auth]: https://github.com/purescript/registry-dev/blob/master/SPEC.md#52-authentication

bin/spago.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package:
22
name: spago-bin
33
publish:
4-
version: 0.93.43
4+
version: 0.93.45
55
license: BSD-3-Clause
66
build:
77
strict: true

bin/src/Main.purs

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,7 @@ main = do
536536
\c -> Aff.launchAff_ case c of
537537
Cmd'SpagoCmd (SpagoCmd globalArgs@{ offline, migrateConfig } command) -> do
538538
logOptions <- mkLogOptions startingTime globalArgs
539-
rootPath <- Path.mkRoot =<< Paths.cwd
540-
runSpago { logOptions, rootPath } case command of
539+
runSpago { logOptions } case command of
541540
Sources args -> do
542541
{ env } <- mkFetchEnv
543542
{ packages: mempty
@@ -552,6 +551,7 @@ main = do
552551
void $ runSpago env (Sources.run { json: args.json })
553552
Init args@{ useSolver } -> do
554553
-- Fetch the registry here so we can select the right package set later
554+
rootPath <- Path.mkRoot =<< Paths.cwd
555555
env <- mkRegistryEnv offline <#> Record.union { rootPath }
556556
setVersion <- parseSetVersion args.setVersion
557557
void $ runSpago env $ Init.run { mode: args.mode, setVersion, useSolver }
@@ -599,7 +599,8 @@ main = do
599599
void $ runSpago publishEnv (Publish.publish {})
600600

601601
Repl args@{ selectedPackage } -> do
602-
packages <- FS.exists (rootPath </> "spago.yaml") >>= case _ of
602+
cwd <- Paths.cwd
603+
packages <- FS.exists (cwd </> "spago.yaml") >>= case _ of
603604
true -> do
604605
-- if we have a config then we assume it's a workspace, and we can run a repl in the project
605606
pure mempty -- TODO newPackages
@@ -661,13 +662,14 @@ main = do
661662
testEnv <- runSpago env (mkTestEnv args buildEnv)
662663
runSpago testEnv Test.run
663664
LsPaths args -> do
664-
runSpago { logOptions, rootPath } $ Ls.listPaths args
665+
let fetchArgs = { packages: mempty, selectedPackage: Nothing, pure: false, ensureRanges: false, testDeps: false, isRepl: false, migrateConfig, offline }
666+
{ env } <- mkFetchEnv fetchArgs
667+
runSpago env $ Ls.listPaths args
665668
LsPackages args@{ pure } -> do
666669
let fetchArgs = { packages: mempty, selectedPackage: Nothing, pure, ensureRanges: false, testDeps: false, isRepl: false, migrateConfig, offline }
667-
{ env: env@{ workspace }, fetchOpts } <- mkFetchEnv fetchArgs
670+
{ env, fetchOpts } <- mkFetchEnv fetchArgs
668671
dependencies <- runSpago env (Fetch.run fetchOpts)
669-
let lsEnv = { workspace, dependencies, logOptions, rootPath }
670-
runSpago lsEnv (Ls.listPackageSet args)
672+
runSpago (Record.union env { dependencies }) (Ls.listPackageSet args)
671673
LsDeps { selectedPackage, json, transitive, pure } -> do
672674
let fetchArgs = { packages: mempty, selectedPackage, pure, ensureRanges: false, testDeps: false, isRepl: false, migrateConfig, offline }
673675
{ env, fetchOpts } <- mkFetchEnv fetchArgs
@@ -690,13 +692,11 @@ main = do
690692
GraphModules args -> do
691693
{ env, fetchOpts } <- mkFetchEnv { packages: mempty, selectedPackage: Nothing, pure: false, ensureRanges: false, testDeps: false, isRepl: false, migrateConfig, offline }
692694
dependencies <- runSpago env (Fetch.run fetchOpts)
693-
purs <- Purs.getPurs
694-
runSpago { dependencies, logOptions, rootPath, purs, workspace: env.workspace } (Graph.graphModules args)
695+
runSpago (Record.union env { dependencies }) (Graph.graphModules args)
695696
GraphPackages args -> do
696697
{ env, fetchOpts } <- mkFetchEnv { packages: mempty, selectedPackage: Nothing, pure: false, ensureRanges: false, testDeps: false, isRepl: false, migrateConfig, offline }
697698
dependencies <- runSpago env (Fetch.run fetchOpts)
698-
purs <- Purs.getPurs
699-
runSpago { dependencies, logOptions, rootPath, purs, workspace: env.workspace } (Graph.graphPackages args)
699+
runSpago (Record.union env { dependencies }) (Graph.graphPackages args)
700700

701701
Cmd'VersionCmd v -> when v do
702702
output (OutputLines [ BuildInfo.packages."spago-bin" ])
@@ -951,7 +951,14 @@ mkReplEnv replArgs dependencies supportPackage = do
951951
, selected
952952
}
953953

954-
mkFetchEnv :: forall a b. { offline :: OnlineStatus, migrateConfig :: Boolean, isRepl :: Boolean | FetchArgsRow b } -> Spago (SpagoBaseEnv a) { env :: Fetch.FetchEnv (), fetchOpts :: Fetch.FetchOpts }
954+
mkFetchEnv
955+
:: a b
956+
. { offline :: OnlineStatus
957+
, migrateConfig :: Boolean
958+
, isRepl :: Boolean
959+
| FetchArgsRow b
960+
}
961+
-> Spago { logOptions :: LogOptions | a } { env :: Fetch.FetchEnv (), fetchOpts :: Fetch.FetchOpts }
955962
mkFetchEnv args@{ migrateConfig, offline } = do
956963
let
957964
parsePackageName p =
@@ -966,24 +973,26 @@ mkFetchEnv args@{ migrateConfig, offline } = do
966973
Left _err -> die $ "Failed to parse selected package name, was: " <> show args.selectedPackage
967974

968975
env <- mkRegistryEnv offline
969-
{ rootPath } <- ask
970-
workspace <-
971-
runSpago (Record.union env { rootPath })
972-
(Config.readWorkspace { maybeSelectedPackage, pureBuild: args.pure, migrateConfig })
976+
cwd <- Paths.cwd
977+
{ workspace, rootPath } <-
978+
runSpago env
979+
(Config.discoverWorkspace { maybeSelectedPackage, pureBuild: args.pure, migrateConfig } cwd)
980+
981+
FS.mkdirp $ rootPath </> Paths.localCachePath
982+
FS.mkdirp $ rootPath </> Paths.localCachePackagesPath
983+
logDebug $ "Workspace root path: " <> Path.quote rootPath
984+
logDebug $ "Local cache: " <> Paths.localCachePath
985+
973986
let fetchOpts = { packages: packageNames, ensureRanges: args.ensureRanges, isTest: args.testDeps, isRepl: args.isRepl }
974987
pure { fetchOpts, env: Record.union { workspace, rootPath } env }
975988

976989
mkRegistryEnv :: forall a. OnlineStatus -> Spago (SpagoBaseEnv a) (Registry.RegistryEnv ())
977990
mkRegistryEnv offline = do
978-
{ logOptions, rootPath } <- ask
991+
{ logOptions } <- ask
979992

980993
-- Take care of the caches
981994
FS.mkdirp Paths.globalCachePath
982-
FS.mkdirp $ rootPath </> Paths.localCachePath
983-
FS.mkdirp $ rootPath </> Paths.localCachePackagesPath
984-
logDebug $ "Workspace root path: " <> Path.quote rootPath
985995
logDebug $ "Global cache: " <> Path.quote Paths.globalCachePath
986-
logDebug $ "Local cache: " <> Paths.localCachePath
987996

988997
-- Make sure we have git and purs
989998
git <- Git.getGit
@@ -1004,7 +1013,7 @@ mkRegistryEnv offline = do
10041013
, db
10051014
}
10061015

1007-
mkLsEnv :: forall a. Fetch.PackageTransitiveDeps -> Spago (Fetch.FetchEnv a) Ls.LsEnv
1016+
mkLsEnv :: a. Fetch.PackageTransitiveDeps -> Spago (Fetch.FetchEnv a) (Ls.LsEnv ())
10081017
mkLsEnv dependencies = do
10091018
{ logOptions, workspace, rootPath } <- ask
10101019
selected <- case workspace.selected of

core/src/Log.purs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ module Spago.Log
2222
, rightOrDie
2323
, rightOrDie_
2424
, rightOrDieWith
25-
, rightOrDieWith'
2625
, toDoc
2726
) where
2827

@@ -185,25 +184,18 @@ justOrDieWith' value msg = case value of
185184
die' msg
186185

187186
rightOrDie :: b m err x. MonadEffect m => MonadAsk (LogEnv b) m => Loggable err => Either err x -> m x
188-
rightOrDie value = rightOrDieWith value identity
187+
rightOrDie = rightOrDieWith identity
189188

190189
rightOrDie_ :: b m err x. MonadEffect m => MonadAsk (LogEnv b) m => Loggable err => Either err x -> m Unit
191190
rightOrDie_ = void <<< rightOrDie
192191

193-
rightOrDieWith :: a b m err x. MonadEffect m => MonadAsk (LogEnv b) m => Loggable a => Either err x -> (err -> a) -> m x
194-
rightOrDieWith value toMsg = case value of
192+
rightOrDieWith :: a b m err x. MonadEffect m => MonadAsk (LogEnv b) m => Loggable a => (err -> a) -> Either err x -> m x
193+
rightOrDieWith toMsg value = case value of
195194
Right a ->
196195
pure a
197196
Left err ->
198197
die $ toMsg err
199198

200-
rightOrDieWith' :: a b m err x. MonadEffect m => MonadAsk (LogEnv b) m => Loggable a => Either err x -> (err -> Array a) -> m x
201-
rightOrDieWith' value toMsg = case value of
202-
Right a ->
203-
pure a
204-
Left err ->
205-
die' $ toMsg err
206-
207199
data OutputFormat a
208200
= OutputJson (CJ.Codec a) a
209201
| OutputYaml (CJ.Codec a) a

core/src/Prelude.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Data.DateTime.Instant (Instant) as Extra
2121
import Data.Either (Either(..), isLeft, isRight, either, hush) as Extra
2222
import Data.Filterable (partition, partitionMap) as Extra
2323
import Data.Foldable (foldMap, for_, foldl, and, or) as Extra
24+
import Data.FoldableWithIndex (forWithIndex_) as Extra
2425
import Data.Function (on) as Extra
2526
import Data.Generic.Rep (class Generic) as Extra
2627
import Data.Identity (Identity(..)) as Extra
@@ -47,7 +48,7 @@ import Partial.Unsafe (unsafeCrashWith)
4748
import Registry.ManifestIndex (ManifestIndex) as Extra
4849
import Registry.Types (PackageName, Version, Range, Location, License, Manifest(..), Metadata(..), Sha256) as Extra
4950
import Spago.Json (printJson, parseJson) as Extra
50-
import Spago.Log (logDebug, logError, logInfo, Docc, logSuccess, logWarn, die, die', justOrDieWith, justOrDieWith', rightOrDie, rightOrDie_, rightOrDieWith, rightOrDieWith', toDoc, indent, indent2, output, LogEnv, LogOptions, OutputFormat(..)) as Extra
51+
import Spago.Log (logDebug, logError, logInfo, Docc, logSuccess, logWarn, die, die', justOrDieWith, justOrDieWith', rightOrDie, rightOrDie_, rightOrDieWith, toDoc, indent, indent2, output, LogEnv, LogOptions, OutputFormat(..)) as Extra
5152
import Spago.Path (RawFilePath, GlobalPath, LocalPath, RootPath, class AppendPath, appendPath, (</>)) as Extra
5253
import Spago.Yaml (YamlDoc, printYaml, parseYaml) as Extra
5354

flake.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
inputs = {
3-
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
3+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
44
purescript-overlay.url = "github:thomashoneyman/purescript-overlay";
55
purescript-overlay.inputs.nixpkgs.follows = "nixpkgs";
66
};

0 commit comments

Comments
 (0)