Skip to content

Commit 5dd06ae

Browse files
Integrate PSA into spago (#955)
1 parent 406e201 commit 5dd06ae

File tree

15 files changed

+1437
-50
lines changed

15 files changed

+1437
-50
lines changed

spaghetto/README.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ When ran from the directory `foo`, Spago will search for a "workspace" config fi
222222

223223
At the end of this process, `foo` and `baz` are the only packages considered.
224224

225+
</details>
226+
225227
### `spago.yml` fields and their meaning
226228

227229
```yml
@@ -238,11 +240,49 @@ package:
238240
# One of three options
239241
# 1. just the package
240242
- packageName
241-
# 2. the package, using the widest possible vesrion range
243+
# 2. the package, using the widest possible version range
242244
- packageName: "*"
243-
# 2. the package, using a specified vesrion range
245+
# 2. the package, using a specified version range
244246
- packageName: ">=1.1.1 <2.0.0"
245247

248+
# optional
249+
build:
250+
# optional, whether to censor warnings from dependency sources,
251+
# project sources, both, or none
252+
censorBuildWarnings:
253+
# one of 4 values:
254+
# 1. Both
255+
"all"
256+
# 2. dependency only
257+
"dependency"
258+
# 3. project only
259+
"project"
260+
# 4. do not censor warnings
261+
"none"
262+
# optional, NonEmptyArray, censor specific codes
263+
censorCodes:
264+
- ShadowedName
265+
# optional, NonEmptyArray, only show specific codes
266+
filterCodes:
267+
- ShadowedName
268+
# optional, whether to show statistics at the end
269+
# of warning/error output and how much informaiton
270+
statVerbosity:
271+
# One of 3 values
272+
# 1. Don't show it
273+
"no-stats"
274+
# 2. Show it and only sum the total warnings/errors
275+
"compact-stats"
276+
# 3. Show it and show total warnings/errors by code
277+
"verbose-stats"
278+
# optional, boolean, whether to show the source code
279+
# corresponding to the error's location
280+
showSource: true
281+
# optional, boolean, counts compiler warnings as compiler errors
282+
strict: false
283+
# optional, Boolean String, persist compiler warnings
284+
stash: true
285+
246286
# optional
247287
bundle:
248288
# optional, Boolean, whether to minify
@@ -345,6 +385,10 @@ workspace:
345385
output: "output"
346386
# optional, Boolean, fail the build if `spago.yml` has redundant/missing packages
347387
pedantic_packages: false
388+
# All of the Package's `buildOptions` fields (e.g. `strict` as shown below)
389+
# can also go here. Any specified here will be used
390+
# if the selected package doesn't specify that option in its configuration
391+
strict: false
348392
```
349393
350394
### FAQs

spaghetto/bin/src/Flags.purs

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,76 @@ import Spago.Prelude
44

55
import ArgParse.Basic (ArgParser)
66
import ArgParse.Basic as ArgParser
7+
import Data.Set.NonEmpty (NonEmptySet)
8+
import Data.Set.NonEmpty as NonEmptySet
9+
import Spago.Core.Config (ShowSourceCode(..))
10+
import Spago.Core.Config as Core
711

812
selectedPackage ArgParser (Maybe String)
913
selectedPackage =
1014
ArgParser.argument [ "--package", "-p" ]
1115
"Select the local project to build"
1216
# ArgParser.optional
1317

18+
strict ArgParser (Maybe Boolean)
19+
strict =
20+
ArgParser.flag [ "--strict" ]
21+
"Promotes project sources' warnings to errors"
22+
# ArgParser.boolean
23+
# ArgParser.optional
24+
25+
censorBuildWarnings ArgParser (Maybe Core.CensorBuildWarnings)
26+
censorBuildWarnings =
27+
ArgParser.argument [ "--censor-build-warnings" ]
28+
"Censor compiler warnings based on file's location: 'dependency', 'project', or 'all'"
29+
# ArgParser.unformat "ARG"
30+
( case _ of
31+
"all" -> Right Core.CensorAllWarnings
32+
"project" -> Right Core.CensorProjectWarnings
33+
"dependency" -> Right Core.CensorDependencyWarnings
34+
_ -> Left $ "Expected 'all', 'project', or 'dependency'"
35+
)
36+
# ArgParser.optional
37+
38+
showSource ArgParser (Maybe ShowSourceCode)
39+
showSource =
40+
NoSourceCode
41+
<$ ArgParser.flag [ "--no-source" ]
42+
"Disable original source code printing"
43+
# ArgParser.optional
44+
45+
censorCodes :: ArgParser (Maybe (NonEmptySet String))
46+
censorCodes =
47+
ArgParser.argument [ "--censor-code" ]
48+
"Censor a specific error code (e.g. `ShadowedName`)"
49+
# ArgParser.many
50+
<#> NonEmptySet.fromFoldable
51+
52+
filterCodes :: ArgParser (Maybe (NonEmptySet String))
53+
filterCodes =
54+
ArgParser.argument [ "--filter-code" ]
55+
"Only show a specific error code (e.g. `TypesDoNotUnify`)"
56+
# ArgParser.many
57+
<#> NonEmptySet.fromFoldable
58+
59+
statVerbosity :: ArgParser (Maybe Core.StatVerbosity)
60+
statVerbosity = ArgParser.optional $ ArgParser.choose "StatVerbosity"
61+
[ Core.VerboseStats <$ ArgParser.flag [ "--verbose-stats" ] "Show counts for each warning type"
62+
, Core.NoStats <$ ArgParser.flag [ "--censor-stats" ] "Censor warning/error summary"
63+
]
64+
65+
persistWarnings ArgParser (Maybe Boolean)
66+
persistWarnings =
67+
ArgParser.flag [ "--persist-warnings" ] "Persist the compiler warnings between multiple underlying `purs compile` calls"
68+
# ArgParser.boolean
69+
# ArgParser.optional
70+
71+
jsonErrors ArgParser Boolean
72+
jsonErrors =
73+
ArgParser.flag [ "--json-errors" ]
74+
"Output compiler warnings/errors as JSON"
75+
# ArgParser.boolean
76+
1477
minify ArgParser Boolean
1578
minify =
1679
ArgParser.flag [ "--minify" ]
@@ -63,7 +126,7 @@ verbose =
63126

64127
noColor ArgParser Boolean
65128
noColor =
66-
ArgParser.flag [ "--no-color" ]
129+
ArgParser.flag [ "--no-color", "--monochrome" ]
67130
"Force logging without ANSI color escape sequences"
68131
# ArgParser.boolean
69132
# ArgParser.default false
@@ -92,7 +155,7 @@ pedanticPackages =
92155
pursArgs ArgParser (List String)
93156
pursArgs =
94157
ArgParser.argument [ "--purs-args" ]
95-
"Arguments to pass to purs compile. Wrap in quotes."
158+
"Arguments to pass to purs compile. Wrap in quotes. `--output` and `--json-errors` must be passed to Spago directly."
96159
# ArgParser.many
97160

98161
execArgs :: ArgParser (Maybe (Array String))

0 commit comments

Comments
 (0)