-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manually order config codecs #1106
Conversation
configCodec = CA.object "Config" | ||
$ CA.recordPropOptional (Proxy :: _ "package") packageConfigCodec | ||
$ CA.recordPropOptional (Proxy :: _ "workspace") workspaceConfigCodec | ||
$ CA.record |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally stuck to the order I saw defined in the type synonyms, with the exception of potentially long lists (like extra_packages), which I generally moved to the end.
Let me know if you want anything ordered differently and it's easy enough to change.
It's an oversight and should be fixed 😄 (Unless we'd rather switch everything to camelCase. I don't have a strong preference) |
One test failure: I had some trouble tracking down where in the code this is exactly happening, but for some reason the test section below is not respecting the codec ordering and is always ordering
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sooo pretty 🙂
This is great - now that we encode the fields manually I'm up for changing the records to be CamelCase if you'd prefer that as well
My bet is on |
Hmm, |
@@ -12,7 +12,7 @@ export function addPackagesToConfigImpl(doc, isTest, newPkgs) { | |||
|
|||
const deps = (() => { | |||
if (isTest) { | |||
const test = getOrElse(pkg, "test", doc.createNode({ dependencies: [], main: "Test.Main" })); | |||
const test = getOrElse(pkg, "test", doc.createNode({ main: "Test.Main", dependencies: [] })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the culprit.
@@ -5,7 +5,7 @@ | |||
[![build](https://github.com/purescript/spago/actions/workflows/build.yml/badge.svg)](https://github.com/purescript/spago/actions/workflows/build.yml) | |||
[![Maintainer: f-f](https://img.shields.io/badge/maintainer-f%2d-f-teal.svg)](http://github.com/f-f) | |||
|
|||
*(IPA: /ˈspaɡo/)* | |||
_(IPA: /ˈspaɡo/)_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I updated this file for the use of execArgs
-> exec_args
and, as I use Prettier, it was auto-formatted. If you want me to revert the changes to this file then I can (though I personally agree with the changes made).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's fine, these changes are fairly harmless
I don't care one way or another, just wanted to check. If we did, it'd look something like this: type MyObject = { blahBlah :: String }
codec = Profunctor.dimap to from $ CA.Record.object "MyObject"
{ blah_blah: CA.string
}
where
to = Record.rename (Proxy :: _ "blah_blah") (Proxy :: _ "blahBlah")
from = Record.rename (Proxy :: _ "blahBlah") (Proxy :: _ "blah_blah") |
Oh I see - I thought it would come for free with the manual encoding, but instead it seems a little tedious so let's keep things as they are |
@@ -5,7 +5,7 @@ | |||
[![build](https://github.com/purescript/spago/actions/workflows/build.yml/badge.svg)](https://github.com/purescript/spago/actions/workflows/build.yml) | |||
[![Maintainer: f-f](https://img.shields.io/badge/maintainer-f%2d-f-teal.svg)](http://github.com/f-f) | |||
|
|||
*(IPA: /ˈspaɡo/)* | |||
_(IPA: /ˈspaɡo/)_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's fine, these changes are fairly harmless
Sorry about that! Renamed just the two now. |
Not sure about the macOS failures — are these flaky?
|
They are flaky, we think they are failing for some reason related to #1048 |
Also now a Windows failure, this time I believe because this line is not expected in the fixture:
Is there a way to control this, perhaps by running all tests in |
I think this is done as far as I'm concerned, so feel free to merge away if you are OK ignoring the tests! |
We need to test the internet-reaching parts too so that's not an option. I believe the issue we're seeing is related to the Windows filesystem being funky (we use the modification time on a file to note down the last time we pulled the registry, and I wouldn't be surprised if this was flaky on Windows) - should be fixed as part of #1083 |
Description of the change
Currently all JSON codecs use the
Codec.Argonaut.Record
module with its record sugar for defining objects. While convenient, this method will always order fields alphabetically in JSON, which isn't what we want in a config file. Instead we should manually order these fields. As an example, a fresh init of a config file will place thedependencies
key before the package'sname
key; they really ought to go the other way around.This PR switches to a manual encoding of the config formats.
Notes
I noticed that we generally reuse the YAML fields directly, such as
exec_args
being typed in PureScript astype ... = { exec_args :: ... }
. If we want to be more purescript-y we can rename these fields in the codecs so the YAML isexec_args
but the PureScript isexecArgs
.The reason this particularly caught my attention is that we generally use snake case in YAML except for
execArgs
, which is camel case. Thought it may have been an oversight. But maybe it's intentional.I'm also seeing some odd test failures but I'll report on them once the suite runs on this PR.