Skip to content
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

Add schema for bun.lock #4368

Merged
merged 12 commits into from
Jan 20, 2025
Merged

Conversation

RiskyMH
Copy link
Contributor

@RiskyMH RiskyMH commented Jan 19, 2025

Based on the TypeScript types I wrote, I have tried to make this into a json schema file. I haven't done this before so please tell me if I did something wrong.

Some things to note:

  • bun.lock always has trailing comma's which I wanted to respect in the tests, however there didn't appear to be any way, so I had to remove them.
  • also with above, the formatter made me format the bun.lock file even though its meant to have each dep as one line
  • I will try to get this schema into vscode so it stops warning about trailing comma (it currently has been told its jsonc)
    • other than this I believe it will help people understand the format (with intelisense), however it could just be "allowTrailingCommas": true, to be boring
  • I believe its better to have the schema in a place like here opposed to on the Bun repo, but what do you guys think (like if we change schema it could be easier)
    • considering there is bunfig.toml here it also makes sense to have the other files
  • announcement: https://bun.sh/blog/bun-lock-text-lockfile

related to #4292

Copy link
Contributor

Thanks for the PR!

This section of the codebase is owned by @madskristensen and @hyperupcall - if they write a comment saying "LGTM" then it will be merged.

@RiskyMH

This comment was marked as resolved.

@hyperupcall
Copy link
Member

hyperupcall commented Jan 20, 2025

Thanks!

bun.lock always has trailing comma's which I wanted to respect in the tests, however there didn't appear to be any way, so I had to remove them.

That's a good point, we don't currently have the testing setup to test that

I will try to get this schema into vscode so it stops warning about trailing comma (it currently has been told its jsonc)

Like you mention "allowTrailingCommas": true,, should prevent this error from being shown. Let me know if it somehow doesn't! I don't know of any way to allow JSONC-style comments, though.

also with above, the formatter made me format the bun.lock file even though its meant to have each dep as one line

If you'd like you can update the Prettier config (.prettierrc.cjs) and add an object under overrides for your file. I think the necessary config you need to prevent sorting is at the top of the file (the jsonSortOrder, jsonSort etc. objects that have keys and values of "none"

Should I merge this or would you like to undo the formatting changes? :)

@RiskyMH
Copy link
Contributor Author

RiskyMH commented Jan 20, 2025

Like you mention "allowTrailingCommas": true,, should prevent this error from being shown. Let me know if it somehow doesn't! I don't #4352 (comment) of any way to allow JSONC-style comments, though.

yeah i abused the bun vscode extension to do this (and it works) https://github.com/oven-sh/bun/pull/15747/files#diff-12be5ecda96b0ebf5d31753a2ff301bc9528afc1c11ff41fb574b6f94925aca5, we also allow comments in parser but don't add any so that isn't much of an issue

ill try to fix formatting changes (still trailing comma difference, but thats minor just like this tbh)

@RiskyMH
Copy link
Contributor Author

RiskyMH commented Jan 20, 2025

i dont know if i disabled prettier right, but it appears to work now!

@hyperupcall
Copy link
Member

Great, thanks!

@hyperupcall hyperupcall merged commit add906b into SchemaStore:master Jan 20, 2025
3 checks passed
@RiskyMH
Copy link
Contributor Author

RiskyMH commented Jan 20, 2025

@hyperupcall thanks for merging this :)

btw i think I mixed up something as https://json.schemastore.org/bun.lock.json doesn't work (i think somewhere i assumed i had to bun-lock.json and didnt use it enough)

sorry about that

@RiskyMH RiskyMH deleted the bun-lock branch January 20, 2025 07:03
@hyperupcall
Copy link
Member

hyperupcall commented Jan 20, 2025

You're good! CI is supposed to catch that type of error (I'll have to look into it later)

Feel free to make another PR fixing any mistakes - I kind of prefer the bun-lock.json if I'm being honest 😅

@RiskyMH
Copy link
Contributor Author

RiskyMH commented Jan 20, 2025

Yeah I think its better as too many .'s get confusing, it more was just me adding it then fixing errors without thinking too hard 😅

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.

2 participants