Skip to content

Commit c942722

Browse files
Merge branch 'master'
2 parents bea2013 + ebf4944 commit c942722

Some content is hidden

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

67 files changed

+1919
-1533
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# nixfmt v0.6.0
2+
c428bcf158275637597b37d683f82248833664c0

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ result
1717

1818
# Keep it secret, keep it safe.
1919
.env
20+
.envrc

SPEC.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,8 @@ These files are always included in the tarball, if present:
427427

428428
These files are always excluded from the tarball, regardless of what is specified in the `files` key:
429429

430-
- `.psci`, `.psci_modules`, `.spago`, `node_modules`, `bower_components`, `.git`, `CVS`, `.svn`, and `.hg` directories.
430+
- `.psci`, `.psci_modules`, `.spago`, `node_modules`, and `bower_components` directories.
431+
- `.git`, `CVS`, `.svn`, `.hg`, `_darcs`, `.fossil`, `.jj`, and `.pijul` <abbr title="version control system">VCS</abbr> directories.
431432
- `package-lock.json`, `yarn.lock`, and `pnpm-lock.yaml` files.
432433
- `.swp`, `._*`, and `.DS_Store` files.
433434

app/default.nix

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@
2020
# from the registry at the top level
2121
spago-lock,
2222
package-lock,
23-
}: let
23+
}:
24+
let
2425
# Since both the importer and the server share the same build process, we
2526
# don't need to build them twice separately and can share an optimized output
2627
# directory.
2728
shared = stdenv.mkDerivation {
2829
name = "registry-app-shared";
2930
src = ./.;
30-
phases = ["buildPhase" "installPhase"];
31-
nativeBuildInputs = [purs-backend-es];
31+
phases = [
32+
"buildPhase"
33+
"installPhase"
34+
];
35+
nativeBuildInputs = [ purs-backend-es ];
3236
buildPhase = ''
3337
ln -s ${package-lock}/js/node_modules .
3438
cp -r ${spago-lock.registry-app}/output .
@@ -40,13 +44,17 @@
4044
mv output-es $out/output
4145
'';
4246
};
43-
in {
47+
in
48+
{
4449
server = stdenv.mkDerivation rec {
4550
name = "registry-server";
4651
src = ./.;
4752
database = ../db;
48-
nativeBuildInputs = [esbuild makeWrapper];
49-
buildInputs = [nodejs];
53+
nativeBuildInputs = [
54+
esbuild
55+
makeWrapper
56+
];
57+
buildInputs = [ nodejs ];
5058
entrypoint = writeText "entrypoint.js" ''
5159
import { main } from "./output/Registry.App.Server";
5260
main();
@@ -74,15 +82,31 @@ in {
7482
'';
7583
postFixup = ''
7684
wrapProgram $out/bin/${name} \
77-
--set PATH ${lib.makeBinPath [compilers purs-versions dhall dhall-json licensee git git-lfs coreutils gzip gnutar]} \
85+
--set PATH ${
86+
lib.makeBinPath [
87+
compilers
88+
purs-versions
89+
dhall
90+
dhall-json
91+
licensee
92+
git
93+
git-lfs
94+
coreutils
95+
gzip
96+
gnutar
97+
]
98+
} \
7899
'';
79100
};
80101

81102
github-importer = stdenv.mkDerivation rec {
82103
name = "registry-github-importer";
83104
src = ./.;
84-
nativeBuildInputs = [esbuild makeWrapper];
85-
buildInputs = [nodejs];
105+
nativeBuildInputs = [
106+
esbuild
107+
makeWrapper
108+
];
109+
buildInputs = [ nodejs ];
86110
entrypoint = writeText "entrypoint.js" ''
87111
import { main } from "./output/Registry.App.GitHubIssue";
88112
main();
@@ -107,7 +131,20 @@ in {
107131
'';
108132
postFixup = ''
109133
wrapProgram $out/bin/${name} \
110-
--set PATH ${lib.makeBinPath [compilers purs-versions dhall dhall-json licensee git git-lfs coreutils gzip gnutar]} \
134+
--set PATH ${
135+
lib.makeBinPath [
136+
compilers
137+
purs-versions
138+
dhall
139+
dhall-json
140+
licensee
141+
git
142+
git-lfs
143+
coreutils
144+
gzip
145+
gnutar
146+
]
147+
} \
111148
'';
112149
};
113150
}

app/spago.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ package:
88
dependencies:
99
- aff
1010
- ansi
11-
- argonaut-core
1211
- arrays
1312
- b64
1413
- bifunctors
15-
- codec-argonaut
14+
- codec
15+
- codec-json
1616
- console
1717
- const
1818
- control
@@ -23,22 +23,23 @@ package:
2323
- either
2424
- exceptions
2525
- exists
26-
- filterable
2726
- fetch
27+
- filterable
2828
- foldable-traversable
29+
- foreign
2930
- foreign-object
3031
- formatters
3132
- http-methods
3233
- httpurple
3334
- identity
3435
- integers
35-
- js-fetch
3636
- js-date
37-
- js-uri
37+
- js-fetch
3838
- js-promise-aff
39+
- js-uri
40+
- json
3941
- lists
4042
- maybe
41-
- media-types
4243
- newtype
4344
- node-buffer
4445
- node-child-process
@@ -56,7 +57,6 @@ package:
5657
- partial
5758
- prelude
5859
- profunctor
59-
- profunctor-lenses
6060
- record
6161
- refs
6262
- registry-foreign

app/src/App/API.purs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ module Registry.App.API
1919

2020
import Registry.App.Prelude
2121

22-
import Data.Argonaut.Parser as Argonaut.Parser
22+
import Codec.JSON.DecodeError as CJ.DecodeError
2323
import Data.Array as Array
2424
import Data.Array.NonEmpty as NonEmptyArray
25-
import Data.Codec.Argonaut as CA
26-
import Data.Codec.Argonaut.Common as CA.Common
27-
import Data.Codec.Argonaut.Record as CA.Record
25+
import Data.Codec.JSON as CJ
26+
import Data.Codec.JSON.Common as CJ.Common
27+
import Data.Codec.JSON.Record as CJ.Record
2828
import Data.Exists as Exists
2929
import Data.Foldable (traverse_)
3030
import Data.FoldableWithIndex (foldMapWithIndex)
@@ -41,6 +41,7 @@ import Data.String.NonEmpty as NonEmptyString
4141
import Data.String.Regex as Regex
4242
import Effect.Aff as Aff
4343
import Effect.Unsafe (unsafePerformEffect)
44+
import JSON as JSON
4445
import Node.ChildProcess.Types (Exit(..))
4546
import Node.FS.Aff as FS.Aff
4647
import Node.FS.Stats as FS.Stats
@@ -436,7 +437,7 @@ publish maybeLegacyIndex payload = do
436437
Except.throw $ "Found a valid purs.json file in the package source, but it does not typecheck."
437438
Right _ -> case parseJson Manifest.codec string of
438439
Left err -> do
439-
Log.error $ "Failed to parse manifest: " <> CA.printJsonDecodeError err
440+
Log.error $ "Failed to parse manifest: " <> CJ.DecodeError.print err
440441
Except.throw $ "Found a purs.json file in the package source, but it could not be decoded."
441442
Right manifest -> do
442443
Log.debug $ "Read a valid purs.json manifest from the package source:\n" <> stringifyJson Manifest.codec manifest
@@ -625,10 +626,10 @@ publish maybeLegacyIndex payload = do
625626
-- unused dependencies. This only affects old packages and we know
626627
-- they compile, so we've decided it's an acceptable exception.
627628
pure $ Tuple (Manifest receivedManifest) validatedResolutions
628-
Right output -> case Argonaut.Parser.jsonParser output of
629+
Right output -> case JSON.parse output of
629630
Left parseErr -> Except.throw $ "Failed to parse purs graph output as JSON while finding unused dependencies: " <> parseErr
630-
Right json -> case CA.decode PursGraph.pursGraphCodec json of
631-
Left decodeErr -> Except.throw $ "Failed to decode JSON from purs graph output while finding unused dependencies: " <> CA.printJsonDecodeError decodeErr
631+
Right json -> case CJ.decode PursGraph.pursGraphCodec json of
632+
Left decodeErr -> Except.throw $ "Failed to decode JSON from purs graph output while finding unused dependencies: " <> CJ.DecodeError.print decodeErr
632633
Right graph -> do
633634
Log.debug "Got a valid graph of source and dependencies."
634635
let
@@ -1031,7 +1032,7 @@ publishToPursuit { source, compiler, resolutions, installedResolutions } = Excep
10311032
let lines = String.split (String.Pattern "\n") publishResult
10321033
case Array.last lines of
10331034
Nothing -> Except.throw "Publishing failed because of an unexpected compiler error. cc @purescript/packaging"
1034-
Just jsonString -> case Argonaut.Parser.jsonParser jsonString of
1035+
Just jsonString -> case JSON.parse jsonString of
10351036
Left err -> Except.throw $ String.joinWith "\n"
10361037
[ "Failed to parse output of publishing. cc @purescript/packaging"
10371038
, "```"
@@ -1050,8 +1051,8 @@ publishToPursuit { source, compiler, resolutions, installedResolutions } = Excep
10501051

10511052
type PursuitResolutions = Map RawPackageName { version :: Version, path :: FilePath }
10521053

1053-
pursuitResolutionsCodec :: JsonCodec PursuitResolutions
1054-
pursuitResolutionsCodec = rawPackageNameMapCodec $ CA.Record.object "Resolution" { version: Version.codec, path: CA.string }
1054+
pursuitResolutionsCodec :: CJ.Codec PursuitResolutions
1055+
pursuitResolutionsCodec = rawPackageNameMapCodec $ CJ.named "Resolution" $ CJ.Record.object { version: Version.codec, path: CJ.string }
10551056

10561057
-- Resolutions format: https://github.com/purescript/purescript/pull/3565
10571058
--
@@ -1344,9 +1345,9 @@ instance FsEncodable CompilerCache where
13441345
cacheKey = baseKey <> Sha256.print hashKey
13451346

13461347
let
1347-
codec = CA.Record.object "FindAllCompilersResult"
1348+
codec = CJ.named "FindAllCompilersResult" $ CJ.Record.object
13481349
{ target: Version.codec
1349-
, result: CA.Common.either compilerFailureCodec CA.null
1350+
, result: CJ.Common.either compilerFailureCodec CJ.null
13501351
}
13511352

13521353
Exists.mkExists $ Cache.AsJson cacheKey codec next

app/src/App/CLI/Licensee.purs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ module Registry.App.CLI.Licensee where
22

33
import Registry.App.Prelude
44

5+
import Codec.JSON.DecodeError as CJ.DecodeError
56
import Control.Parallel as Parallel
67
import Data.Array as Array
7-
import Data.Codec.Argonaut as CA
8-
import Data.Codec.Argonaut.Record as CA.Record
8+
import Data.Codec.JSON as CJ
9+
import Data.Codec.JSON.Record as CJ.Record
910
import Node.ChildProcess.Types (Exit(..))
1011
import Node.FS.Aff as FS
1112
import Node.Library.Execa as Execa
@@ -32,15 +33,15 @@ detect directory = do
3233
-- but we consider this valid Licensee output.
3334
Normally n | n == 0 || n == 1 -> do
3435
let
35-
parse :: String -> Either JsonDecodeError (Array String)
36-
parse str = map (map _.spdx_id <<< _.licenses) $ flip parseJson str $ CA.Record.object "Licenses"
37-
{ licenses: CA.array $ CA.Record.object "SPDXIds"
38-
{ spdx_id: CA.string }
36+
parse :: String -> Either CJ.DecodeError (Array String)
37+
parse str = map (map _.spdx_id <<< _.licenses) $ flip parseJson str $ CJ.named "Licenses" $ CJ.Record.object
38+
{ licenses: CJ.array $ CJ.named "SPDXIds" $ CJ.Record.object
39+
{ spdx_id: CJ.string }
3940
}
4041

4142
case parse result.stdout of
4243
Left error -> do
43-
let printedError = CA.printJsonDecodeError error
44+
let printedError = CJ.DecodeError.print error
4445
Left printedError
4546
Right out -> do
4647
-- A NOASSERTION result means that a LICENSE file could not be parsed.

app/src/App/CLI/Purs.purs

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ module Registry.App.CLI.Purs where
22

33
import Registry.App.Prelude
44

5+
import Codec.JSON.DecodeError as CJ.DecodeError
56
import Data.Array as Array
6-
import Data.Codec.Argonaut as CA
7-
import Data.Codec.Argonaut.Compat as CA.Compat
8-
import Data.Codec.Argonaut.Record as CA.Record
7+
import Data.Codec as Codec
8+
import Data.Codec.JSON as CJ
9+
import Data.Codec.JSON.Common as CJ.Common
10+
import Data.Codec.JSON.Record as CJ.Record
911
import Data.Foldable (foldMap)
1012
import Data.String as String
1113
import Node.ChildProcess.Types (Exit(..))
@@ -34,20 +36,20 @@ data CompilerFailure
3436
derive instance Eq CompilerFailure
3537
derive instance Ord CompilerFailure
3638

37-
compilerFailureCodec :: JsonCodec CompilerFailure
38-
compilerFailureCodec = CA.codec' decode encode
39+
compilerFailureCodec :: CJ.Codec CompilerFailure
40+
compilerFailureCodec = Codec.codec' decode encode
3941
where
40-
decode :: Json -> Either JsonDecodeError CompilerFailure
41-
decode json =
42-
map CompilationError (CA.decode (CA.array compilerErrorCodec) json)
43-
<|> map UnknownError (CA.decode CA.string json)
44-
<|> map (const MissingCompiler) (CA.decode CA.null json)
42+
decode :: JSON -> Except CJ.DecodeError CompilerFailure
43+
decode json = except do
44+
map CompilationError (CJ.decode (CJ.array compilerErrorCodec) json)
45+
<|> map UnknownError (CJ.decode CJ.string json)
46+
<|> map (const MissingCompiler) (CJ.decode CJ.null json)
4547

46-
encode :: CompilerFailure -> Json
48+
encode :: CompilerFailure -> JSON
4749
encode = case _ of
48-
CompilationError errors -> CA.encode (CA.array compilerErrorCodec) errors
49-
UnknownError message -> CA.encode CA.string message
50-
MissingCompiler -> CA.encode CA.null unit
50+
CompilationError errors -> CJ.encode (CJ.array compilerErrorCodec) errors
51+
UnknownError message -> CJ.encode CJ.string message
52+
MissingCompiler -> CJ.encode CJ.null unit
5153

5254
type CompilerError =
5355
{ position :: SourcePosition
@@ -58,14 +60,14 @@ type CompilerError =
5860
, moduleName :: Maybe String
5961
}
6062

61-
compilerErrorCodec :: JsonCodec CompilerError
62-
compilerErrorCodec = CA.Record.object "CompilerError"
63+
compilerErrorCodec :: CJ.Codec CompilerError
64+
compilerErrorCodec = CJ.named "CompilerError" $ CJ.Record.object
6365
{ position: sourcePositionCodec
64-
, message: CA.string
65-
, errorCode: CA.string
66-
, errorLink: CA.string
67-
, filename: CA.string
68-
, moduleName: CA.Compat.maybe CA.string
66+
, message: CJ.string
67+
, errorCode: CJ.string
68+
, errorLink: CJ.string
69+
, filename: CJ.string
70+
, moduleName: CJ.Common.nullable CJ.string
6971
}
7072

7173
type SourcePosition =
@@ -75,12 +77,12 @@ type SourcePosition =
7577
, endColumn :: Int
7678
}
7779

78-
sourcePositionCodec :: JsonCodec SourcePosition
79-
sourcePositionCodec = CA.Record.object "SourcePosition"
80-
{ startLine: CA.int
81-
, startColumn: CA.int
82-
, endLine: CA.int
83-
, endColumn: CA.int
80+
sourcePositionCodec :: CJ.Codec SourcePosition
81+
sourcePositionCodec = CJ.named "SourcePosition" $ CJ.Record.object
82+
{ startLine: CJ.int
83+
, startColumn: CJ.int
84+
, endLine: CJ.int
85+
, endColumn: CJ.int
8486
}
8587

8688
-- TODO: This would be better handled with dodo-printer.
@@ -146,8 +148,8 @@ callCompiler compilerArgs = do
146148
$ String.replaceAll (String.Pattern ".") (String.Replacement "_")
147149
$ Version.print version
148150

149-
errorsCodec = CA.Record.object "CompilerErrors"
150-
{ errors: CA.array compilerErrorCodec
151+
errorsCodec = CJ.named "CompilerErrors" $ CJ.Record.object
152+
{ errors: CJ.array compilerErrorCodec
151153
}
152154

153155
result <- _.getResult =<< Execa.execa purs (printCommand compilerArgs.command) (_ { cwd = compilerArgs.cwd })
@@ -163,7 +165,7 @@ callCompiler compilerArgs = do
163165
Just version | Right min <- Version.parse "0.14.0", version < min -> result.stderr
164166
Just _ -> result.stdout
165167
case parseJson errorsCodec output of
166-
Left err -> UnknownError $ String.joinWith "\n" [ result.stdout, result.stderr, CA.printJsonDecodeError err ]
168+
Left err -> UnknownError $ String.joinWith "\n" [ result.stdout, result.stderr, CJ.DecodeError.print err ]
167169
Right ({ errors } :: { errors :: Array CompilerError })
168170
| Array.null errors -> UnknownError "Non-normal exit code, but no errors reported."
169171
| otherwise -> CompilationError errors

0 commit comments

Comments
 (0)