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
feat(pkg-manifest): preserve comments in YAML manifests #6273
Draft
danielbayley
wants to merge
1
commit into
pnpm:main
Choose a base branch
from
danielbayley:preserve-yaml-comments
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
pkg-manifest/read-project-manifest/fixtures/commented-package-yaml/modified.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This is an example of a package.yaml file with comments. | ||
|
||
# pnpm should keep comments at the same indentation level | ||
name: 'foo' | ||
version: '1.0.0' # it should keep in-line comments on the same line | ||
# It should allow in-line comments with no other content | ||
type: 'commonjs' | ||
|
||
# And it should preserve comments at the end of the file. Note no newline. |
9 changes: 9 additions & 0 deletions
9
pkg-manifest/read-project-manifest/fixtures/commented-package-yaml/package.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This is an example of a package.yaml file with comments. | ||
|
||
# pnpm should keep comments at the same indentation level | ||
name: 'foo' | ||
version: '1.0.0' # it should keep in-line comments on the same line | ||
# It should allow in-line comments with no other content | ||
type: 'module' | ||
|
||
# And it should preserve comments at the end of the file. Note no newline. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
we use
js-yaml
we shouldn't use 2 libraries for parsing yaml.
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.
@danielbayley, can you update the suggestion given by @zkochan?
I am desperate to preserve the comments in the
pakcage.yaml
.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.
@zkochan I agree that 2 is not ideal… I suppose I’m proposing that we replace
js-yaml
with eemeli.org/yaml
, because it retains comments very well, whereasjs-yaml
does not, and instead just discards them. Did you take a look at my working implementation here? #2008 (comment)@gusbemacbe Unfortunately it isn’t a suggestion that helps with this implementation…
Same!
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.
With a bit more research, I'd also be in favor of a move to
yaml
. It looks likejs-yaml
hasn't had a release for a few years.Switching to
yaml
to avoid 2 libraries for parsing/serializing YAML files will take a bit of work though.pnpm-lock.yaml
file betweenyaml
vsjs-yaml
.js-yaml
that we'll need to replicate inyaml
. nodeca/js-yaml@master...pnpm:js-yaml:features-for-pnpm@danielbayley Do you happen to have bandwidth for such an investigation? If not, we can spin up a different pull request investigating a switch from
js-yaml
toyaml
that would merge before this PR.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.
Unfortunately not, currently.
@gluxon Fully in favour of the switch… and definitely agree that should be a separate PR, preceding this one. I would be keen to pick up the baton after that to implement comment preservation…
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.
Sounds good! Thanks @danielbayley.