Repository navigation
Use yaml package to parse yaml - #2083
Conversation
🦋 Changeset detectedLatest commit: 0c4d12b The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2083 +/- ##
==========================================
- Coverage 81.43% 81.34% -0.10%
==========================================
Files 62 62
Lines 2349 2348 -1
Branches 646 645 -1
==========================================
- Hits 1913 1910 -3
- Misses 391 393 +2
Partials 45 45 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| let releases: Release[]; | ||
| let yamlStuff: Record<string, VersionType> | undefined; | ||
| let yamlStuff: unknown; |
There was a problem hiding this comment.
I use unknown here so the functions later can validate it better. Maybe we can also refactor to use valibot validate the object
There was a problem hiding this comment.
in here, it would probably be enough to just use plain JS checks to validate the parsed name+type are of correct types (if that's not guaranteed already)
| let yamlStuff: unknown; | ||
| try { | ||
| yamlStuff = yaml.load(roughReleases) as typeof yamlStuff; | ||
| yamlStuff = yaml.parse(roughReleases.trim()); |
There was a problem hiding this comment.
This trim is needed because the regex that extracts the frontmatter would including a trailing \r, which yaml does not treat as a new-line.
I could fix this by updating the regex to handle \r\n, or trim like this. I'm fine with any approach.
There was a problem hiding this comment.
I'd prefer updating the regex here but it's not a big deal either way. Do we have tests for the \r stuff?
There was a problem hiding this comment.
I'll update the regex then. Yeah it's because a test fail that I found this
js-yaml recently got larger due to sourcemaps, so yaml is smaller now. yaml is also technically more spec-compliant, but not likely to affect us in practice anyways.
when yaml v3 releases, it'll also be much smaller