Skip to content

Commit 9e83d87

Browse files
authored
Switch config to camelCase and support automatic migrations (purescript#1202)
1 parent 40c54d6 commit 9e83d87

30 files changed

+407
-222
lines changed

README.md

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,15 @@ In **all** cases, you'll want to switch to the new Registry package sets, so rep
213213

214214
```yaml
215215
workspace:
216-
package_set:
216+
packageSet:
217217
url: https://raw.githubusercontent.com/purescript/package-sets/psc-0.15.10-20230919/packages.json
218218
```
219219
220220
...with this:
221221
222222
```yaml
223223
workspace:
224-
package_set:
224+
packageSet:
225225
registry: 41.2.0
226226
```
227227
@@ -386,7 +386,7 @@ spago run -p package-name --purs-args "--verbose-errors"
386386
# package:
387387
# run:
388388
# main: Main
389-
# exec_args:
389+
# execArgs:
390390
# - "arg1"
391391
# - "arg2"
392392
$ spago run -p package-name
@@ -481,14 +481,14 @@ in there, but thankfully I figure how to fix it. So I clone it locally and add m
481481

482482
Now if I want to test this version in my current project, how can I tell `spago` to do it?
483483

484-
There's a section of the `spago.yaml` file just for that, called `extra_packages`.
484+
There's a section of the `spago.yaml` file just for that, called `extraPackages`.
485485

486486
In this case we override the package with its local copy, which should have a `spago.yaml` - our `workspace` will look something like this:
487487

488488
```yaml
489489
workspace:
490490
registry: 41.2.0
491-
extra_packages:
491+
extraPackages:
492492
aff:
493493
path: ../my-purescript-aff
494494
```
@@ -520,7 +520,7 @@ In this case, we can just change the override to point to some commit of our for
520520
```yaml
521521
workspace:
522522
registry: 41.2.0
523-
extra_packages:
523+
extraPackages:
524524
aff:
525525
git: https://github.com/my-user/purescript-aff.git
526526
ref: aaa0aca7a77af368caa221a2a06d6be2079d32da
@@ -535,14 +535,14 @@ workspace:
535535
> [!IMPORTANT]\
536536
> You still need to `spago install my-new-package` after adding it to the package set, or Spago will not know that you want to use it as a dependency!
537537

538-
If a package is not in the upstream package set, you can add it exactly in the same way, by adding it to `extra_packages`.
538+
If a package is not in the upstream package set, you can add it exactly in the same way, by adding it to `extraPackages`.
539539

540540
E.g. if we want to add the `facebook` package:
541541

542542
```yaml
543543
workspace:
544544
registry: 41.2.0
545-
extra_packages:
545+
extraPackages:
546546
facebook:
547547
git: https://github.com/Unisay/purescript-facebook.git
548548
ref: v0.3.0 # branch, tag, or commit hash
@@ -557,7 +557,7 @@ As you might expect, this works also in the case of adding local packages:
557557
```yaml
558558
workspace:
559559
registry: 41.2.0
560-
extra_packages:
560+
extraPackages:
561561
facebook:
562562
path: ../my-purescript-facebook
563563
```
@@ -596,7 +596,7 @@ will try to put together a new build plan with the latest package versions publi
596596
If instead you are using package sets, then `spago upgrade` will bump your package set version to the latest package set available for your compiler version.
597597

598598
You can pass the `--package-set` flag if you'd rather upgrade to a specific package set version.
599-
You can of course just edit the `workspace.package_set` field in the `spago.yaml` file.
599+
You can of course just edit the `workspace.packageSet` field in the `spago.yaml` file.
600600

601601
### Custom package sets
602602

@@ -606,21 +606,21 @@ Spago will be happy to use a package set from a local path:
606606

607607
```yaml
608608
workspace:
609-
package_set:
609+
packageSet:
610610
path: ../my-custom-package-set.json
611611
```
612612

613613
Otherwise you can point Spago to any URL on the internet:
614614

615615
```yaml
616616
workspace:
617-
package_set:
617+
packageSet:
618618
url: https://raw.githubusercontent.com/purescript/package-sets/psc-0.15.7-20230207/packages.json
619619
```
620620

621621
...and it will try to fetch the content, parse it as JSON and conform it to one of the possible package set schemas.
622622

623-
The first one is what Spago calls a `RemotePackageSet`, which contains some metadata, and a map of packages in the shapes (2), (3) and (4) described for `extra_packages` in the [configuration format section](#the-configuration-file).
623+
The first one is what Spago calls a `RemotePackageSet`, which contains some metadata, and a map of packages in the shapes (2), (3) and (4) described for `extraPackages` in the [configuration format section](#the-configuration-file).
624624

625625
This package set could look something like this:
626626

@@ -643,7 +643,7 @@ This package set could look something like this:
643643
}
644644
```
645645

646-
The second format possible is what Spago calls a `LegacyPackageSet`, and it's simply a map from package names to the location of the package, described as the (4) option for how to specify `extra_packages` in the [configuration format section](#the-configuration-file).
646+
The second format possible is what Spago calls a `LegacyPackageSet`, and it's simply a map from package names to the location of the package, described as the (4) option for how to specify `extraPackages` in the [configuration format section](#the-configuration-file).
647647

648648
Something like this:
649649

@@ -746,7 +746,7 @@ Where:
746746

747747
```yaml
748748
workspace:
749-
package_set:
749+
packageSet:
750750
registry: 41.2.0
751751
```
752752

@@ -853,9 +853,9 @@ Then the `client/spago.yaml` might look like this:
853853

854854
```yaml
855855
workspace:
856-
package_set:
856+
packageSet:
857857
registry: 41.2.0
858-
extra_packages:
858+
extraPackages:
859859
common:
860860
path: ../common
861861
package:
@@ -870,11 +870,11 @@ And the `server/spago.yaml` might look like this:
870870

871871
```yaml
872872
workspace:
873-
package_set:
873+
packageSet:
874874
url: https://raw.githubusercontent.com/purerl/package-sets/erl-0.15.3-20220629/packages.json
875875
backend:
876876
cmd: purerl
877-
extra_packages:
877+
extraPackages:
878878
common:
879879
path: ../common
880880
package:
@@ -1130,7 +1130,7 @@ Packages on which your project depends on can come from a few different sources:
11301130
- local packages - i.e. packages that are on your filesystem but external to your repository
11311131
- remote packages - i.e. packages that are not on your filesystem, but somewhere on the internet
11321132

1133-
The bulk of the packages in your build will come from the Registry (often via a package set), but you are able to add local and remote packages to your build as well, by adding them to the `workspace.extra_packages` section of your `spago.yaml` file.
1133+
The bulk of the packages in your build will come from the Registry (often via a package set), but you are able to add local and remote packages to your build as well, by adding them to the `workspace.extraPackages` section of your `spago.yaml` file.
11341134

11351135
See [here](#add-a-package-to-the-package-set) and [here](#the-configuration-file) for more info about how to add these "extra packages".
11361136

@@ -1198,9 +1198,9 @@ Or it can be more complex, e.g.:
11981198
11991199
```yaml
12001200
workspace:
1201-
package_set:
1201+
packageSet:
12021202
url: https://raw.githubusercontent.com/some-user/custom-package-sets/some-release/packages.json
1203-
extra_packages:
1203+
extraPackages:
12041204
aff:
12051205
path: ../my-purescript-aff
12061206
```
@@ -1222,10 +1222,10 @@ This section documents all the possible fields that can be present in the `spago
12221222
# which will only contain the `package` section.
12231223
workspace:
12241224

1225-
# The package_set field defines where to fetch the package set from.
1225+
# The packageSet field defines where to fetch the package set from.
12261226
# It's optional - not defining this field will make Spago use the
12271227
# Registry solver instead, to come up with a build plan.
1228-
package_set:
1228+
packageSet:
12291229
# It could either be a pointer to the official registry sets that
12301230
# live at https://github.com/purescript/registry/tree/main/package-sets
12311231
registry: 11.10.0
@@ -1238,7 +1238,7 @@ workspace:
12381238
# This section defines any other packages that you'd like to include
12391239
# in the build. It's optional, in case you just want to use the ones
12401240
# coming from the Registry/package set.
1241-
extra_packages:
1241+
extraPackages:
12421242
# Packages are always specified as a mapping from "package name" to
12431243
# "where to find them", and there are quite a few ways to define
12441244
# these locations:
@@ -1296,33 +1296,33 @@ workspace:
12961296
lock: false
12971297

12981298
# Optional section to further customise the build.
1299-
build_opts:
1299+
buildOpts:
13001300
# Directory for the compiler products - optional, defaults to `output`.
13011301
output: "output"
13021302
# Specify whether to censor warnings coming from the compiler
13031303
# for files in the `.spago` directory`.
13041304
# Optional and can be one of two possible values
1305-
censor_library_warnings:
1305+
censorLibraryWarnings:
13061306
# Value 1: "all" - All warnings are censored
13071307
all
13081308

1309-
# Value 2: `NonEmptyArray (Either String { by_prefix :: String })`
1309+
# Value 2: `NonEmptyArray (Either String { byPrefix :: String })`
13101310
# - String values:
13111311
# censor warnings if the code matches this code
1312-
# - { by_prefix } values:
1312+
# - { byPrefix } values:
13131313
# censor warnings if the warning's message
13141314
# starts with the given text
13151315
- CodeName
1316-
# Note: when using `by_prefix`, use the `>` for block-string:
1316+
# Note: when using `byPrefix`, use the `>` for block-string:
13171317
# see https://yaml-multiline.info/
1318-
- by_prefix: >
1318+
- byPrefix: >
13191319
"Data.Map"'s `Semigroup instance`
13201320
13211321
# Specify whether to show statistics at the end of the compilation,
13221322
# and how verbose they should be.
13231323
# Can be 'no-stats', 'compact-stats' (default), or 'verbose-stats',
13241324
# which breaks down the statistics by warning code.
1325-
stat_verbosity: "compact-stats"
1325+
statVerbosity: "compact-stats"
13261326

13271327
# This is the only other section that can be present at the top level.
13281328
# It specifies the configuration for a package in the current folder,
@@ -1353,25 +1353,25 @@ package:
13531353
build:
13541354
# Fail the build if this package's `dependencies` field has redundant/underspecified packages.
13551355
# Optional boolean that defaults to `false`.
1356-
pedantic_packages: false
1356+
pedanticPackages: false
13571357

13581358
# Specify whether to censor warnings coming from the compiler
13591359
# for files from this package.
13601360
# Optional and can be one of two possible values
1361-
censor_project_warnings:
1361+
censorProjectWarnings:
13621362
# Value 1: "all" - All warnings are censored
13631363
all
13641364

1365-
# Value 2: `NonEmptyArray (Either String { by_prefix :: String })`
1365+
# Value 2: `NonEmptyArray (Either String { byPrefix :: String })`
13661366
# - String values:
13671367
# censor warnings if the code matches this code
1368-
# - { by_prefix } values:
1368+
# - { byPrefix } values:
13691369
# censor warnings if the warning's message
13701370
# starts with the given text
13711371
- CodeName
1372-
# Note: when using `by_prefix`, use the `>` for block-string:
1372+
# Note: when using `byPrefix`, use the `>` for block-string:
13731373
# see https://yaml-multiline.info/
1374-
- by_prefix: >
1374+
- byPrefix: >
13751375
"Data.Map"'s `Semigroup instance`
13761376
# Convert compiler warnings for files in this package's src code
13771377
# into errors that can fail the build.
@@ -1403,7 +1403,7 @@ package:
14031403
# The entrypoint for the program
14041404
main: Main
14051405
# List of arguments to pass to the program
1406-
exec_args:
1406+
execArgs:
14071407
- "--cli-arg"
14081408
- "foo"
14091409

@@ -1415,31 +1415,31 @@ package:
14151415
dependencies:
14161416
- foo
14171417
# Optional list of arguments to pass to the test program
1418-
exec_args:
1418+
execArgs:
14191419
- "--cli-arg"
14201420
- "foo"
14211421

14221422
# Fail the build if this package's test's `dependencies` field has redundant/underspecified packages.
14231423
# Optional boolean that defaults to `false`.
1424-
pedantic_packages: false
1424+
pedanticPackages: false
14251425

14261426
# Specify whether to censor warnings coming from the compiler
14271427
# for files from this package's test code.
14281428
# Optional and can be one of two possible values
1429-
censor_test_warnings:
1429+
censorTestWarnings:
14301430
# Value 1: "all" - All warnings are censored
14311431
all
14321432

1433-
# Value 2: `NonEmptyArray (Either String { by_prefix :: String })`
1433+
# Value 2: `NonEmptyArray (Either String { byPrefix :: String })`
14341434
# - String values:
14351435
# censor warnings if the code matches this code
1436-
# - { by_prefix } values:
1436+
# - { byPrefix } values:
14371437
# censor warnings if the warning's message
14381438
# starts with the given text
14391439
- CodeName
1440-
# Note: when using `by_prefix`, use the `>` for block-string:
1440+
# Note: when using `byPrefix`, use the `>` for block-string:
14411441
# see https://yaml-multiline.info/
1442-
- by_prefix: >
1442+
- byPrefix: >
14431443
"Data.Map"'s `Semigroup instance`
14441444
# Convert compiler warnings for files from this package's test code
14451445
# into errors that can fail the build.

bin/src/Flags.purs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ output =
9696
<> O.metavar "DIR"
9797
)
9898

99+
migrateConfig :: Parser Boolean
100+
migrateConfig =
101+
O.switch
102+
( O.long "migrate"
103+
<> O.help "Migrate the spago.yaml file to the latest format"
104+
)
105+
99106
quiet :: Parser Boolean
100107
quiet =
101108
O.switch

0 commit comments

Comments
 (0)