Skip to content

Use yaml package to parse yaml - #2083

Merged
bluwy merged 3 commits into
mainfrom
yaml-parse
Jun 10, 2026
Merged

bluwy merged 3 commits into
mainfrom
yaml-parse

Conversation

@bluwy

@bluwy bluwy commented Jun 10, 2026

Copy link
Copy Markdown
Member

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

@changeset-bot

changeset-bot Bot commented Jun 10, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0c4d12b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@changesets/parse Patch
@changesets/read Patch
@changesets/cli Patch
@changesets/get-release-plan Patch
@changesets/release-utils Patch

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

@socket-security

socket-security Bot commented Jun 10, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedyaml@​2.9.010010010090100

View full report

@codecov

codecov Bot commented Jun 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.34%. Comparing base (3c2573f) to head (0c4d12b).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


let releases: Release[];
let yamlStuff: Record<string, VersionType> | undefined;
let yamlStuff: unknown;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use unknown here so the functions later can validate it better. Maybe we can also refactor to use valibot validate the object

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread packages/parse/src/index.ts Outdated
let yamlStuff: unknown;
try {
yamlStuff = yaml.load(roughReleases) as typeof yamlStuff;
yamlStuff = yaml.parse(roughReleases.trim());

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer updating the regex here but it's not a big deal either way. Do we have tests for the \r stuff?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update the regex then. Yeah it's because a test fail that I found this

@bluwy
bluwy added this pull request to the merge queue Jun 10, 2026
Merged via the queue into main with commit 1c1ded3 Jun 10, 2026
11 of 12 checks passed
@bluwy
bluwy deleted the yaml-parse branch June 10, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants