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

Bump version of pubspec #2197

Closed
JasCodes opened this issue Sep 2, 2019 · 10 comments
Closed

Bump version of pubspec #2197

JasCodes opened this issue Sep 2, 2019 · 10 comments
Labels
contributions-welcome Contributions welcome to help resolve this (the resolution is expected to be clear from the issue) type-enhancement A request for a change that isn't a bug

Comments

@JasCodes
Copy link

JasCodes commented Sep 2, 2019

Cli should allow to bump version major, minor build

Thx

@jonasfj jonasfj added the contributions-welcome Contributions welcome to help resolve this (the resolution is expected to be clear from the issue) label Sep 2, 2019
@jonasfj
Copy link
Member

jonasfj commented Sep 2, 2019

Anything that mutates the pubspec.yaml will require:
A) that we strip all formatting and comments
B) That we write a library that modify YAML without throwing away all comments.

(A) has significant downsides as it's common to comment out dependency_overrides and other hacks used during development. But it might be what we end up doing.

If anyone is interested in taking on (B) writing an abstract syntax tree for YAML and support mutating it that would make adding this feature very easy.

@JasCodes
Copy link
Author

JasCodes commented Sep 7, 2019

Or C we only parse out version key rather then fully implementing whole YAML implementation 😛

@jakemac53
Copy link
Contributor

Parsing out the version key is harder than you would think - yaml has like a billion ways of doing the same thing.

That being said you could use the source code information from the parsed yaml to specifically edit that node without to much headache I think. I don't know if it is really worth doing though and would be a potential source of bugs and/or race conditions.

@JasCodes
Copy link
Author

@jacob314 You might be right, I might just going with sed command in my script. I know its no trivial task to implement full yaml spec in dart.

Thx

@jonasfj
Copy link
Member

jonasfj commented Sep 10, 2019

@JasCodes, so @sigurdm suggested it might be possible by forking dart-lang/yaml, extending the scanner to emit comments for which there is currently no token type. Then it might be possible to write something that mutates the token stream and rebuild a YAML string from the token stream.
This would probably be a pain retain formatting, but if comments are retained that might be good enough :)
If anyone wants to give this approach a go, by all means raise your hand (I'm happy to give feedback/reviews, etc -- I suspect it'll be a bit of work).

@Levi-Lesches
Copy link
Contributor

Levi-Lesches commented Jul 27, 2021

Check out the package cider on pub.dev (not mine). The cider bump command can bump any part of the version, such as:

  • breaking (means y for 0.y.z and x for x.y.z)
  • major
  • minor
  • patch
  • build
  • pre (short for pre-release)

Here are a few sample commands:

  1. Read the current version
cider version
  1. Change the version number to 1.2.3
cider version 1.2.3
  1. Bump to a new breaking version. For 1.2.3, will update to 2.0.0, and for 0.1.2, will update to 0.2.0
cider bump breaking
  1. Bump the major version, regardless of pre-1.0.0 releases
cider bump major

@sigurdm
Copy link
Contributor

sigurdm commented Aug 5, 2021

Note this has a WIP PR: #2617 . Not sure when we'll get back to that...

@Levi-Lesches
Copy link
Contributor

@sigurdm, If you want the bump functionality, why not just officially merge the cider package (or at least that part of it) into pub? As per f3ath/cider#4, they fixed the issue of comments and formatting by simply using regex and not a YAML parser. @f3ath, what do you think?

@f3ath
Copy link

f3ath commented Aug 5, 2021

@Levi-Lesches I have no objection to merging any part of Cider code into pub, but regex does indeed seem too hacky for an official tool.

@sigurdm
Copy link
Contributor

sigurdm commented Aug 6, 2021

but regex does indeed seem too hacky for an official tool.

Yeah - especially now that we have made the actual yaml-edit tool.

@sigurdm sigurdm added the type-enhancement A request for a change that isn't a bug label Feb 21, 2023
@sigurdm sigurdm closed this as completed Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions-welcome Contributions welcome to help resolve this (the resolution is expected to be clear from the issue) type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants