-
-
Notifications
You must be signed in to change notification settings - Fork 960
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
Improve package version detection using jq, python and node #441
Improve package version detection using jq, python and node #441
Conversation
959ac05
to
6e700d5
Compare
The fact that grep solution looks for nested versions is the actual bug, that's why I was saying that there's no place for grep approach in this section. Here's the full package.json from the picture you shared, this section must have retrieved only parent version: https://github.com/NativeScript/sample-Groceries/blob/master/package.json |
@salmanulfarzy I believe using I discussed alternatives and my opinion on this topic in #439. |
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.
As a practical suggestion: I think you could avoid some controversy by reverting the grep
regex exactly back to what it was before (the user would then need to install jq
to fix their bug). That would make this PR strictly better than what's on trunk, although you would have to accept that the jq
and grep
code paths may differ in behavior.
Or, you could land as-is (or with my suggested regex switch), in which case I still think this is better than the state of master
. But this risks breaking other cases.
You could always debate a follow-up PR to swap in node
as the fallback option. But please should check spaceship::exists node
to be safe.
Suggestion by @Darkhogg to use Left notes on
New changes works on this file. |
Co-Authored-By: salmanulfarzy <salmanulfarzy@gmail.com>
Co-Authored-By: salmanulfarzy <salmanulfarzy@gmail.com>
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.
Awesome 👍
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.
Looks OK for now. I think you can merge it @salmanulfarzy.
However, I have a few doubts about this section overall. This section was built for showing package version, speaking about any package manager and not only npm
. Right now it tries to parse JSON (because we know that package.json
is JSON). Nevertheless, not every package manager uses JSON, some of them uses YAML, TOML, etc syntax.
I'm thinking about moving this section out of the Spaceship and distribute as an optional third-party section.
@denysdovhan What's spaceship's API to add in third-party modules? I filed #318 a while back because I felt support was lacking--but let me know if things have changed since then. |
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.
Looks better now.
Commits are mess in this now, Will merge after fixing that 😄 |
* origin/4.0: (44 commits) 3.8.0 Support multiple files for COMPOSE_FILE in docker (spaceship-prompt#395) Add Terraform Workspace section (spaceship-prompt#542) Document kubecontext showing namepace (spaceship-prompt#566) Use Zsh field splitting instead of awk (spaceship-prompt#544) Add namespace to k8s section (spaceship-prompt#565) 3.7.2 Document go.mod detection in golang section Improve package version detection using jq, python and node (spaceship-prompt#441) Truncate .git directory and childs like normal directories (spaceship-prompt#417) Add option to toggle verbose rust version (spaceship-prompt#521) Change font suggestion: Fira Mono → Fira Code Support go.mod files and fix GOPATH matching (spaceship-prompt#559) Hide PR template guidance behind comments (spaceship-prompt#556) Document pyproject.toml in pyenv section (spaceship-prompt#551) 3.7.1 Recognize pyproject.toml when showing pyenv section (spaceship-prompt#550) Fix orderd list count on CONTRIBUTING page (spaceship-prompt#548) Add image in doc for powerline dir lock symbol (spaceship-prompt#517) Remove argument from char test shebang (spaceship-prompt#533) ...
…p-prompt#441) Co-Authored-By: Daniel Escoz <darkhogg@gmail.com> Co-Authored-By: Runrioter Wung <runrioter@qq.com> Co-Authored-By: Nate Fischer <nfischer@users.noreply.github.com>
Co-Authored-By: Daniel Escoz <darkhogg@gmail.com> Co-Authored-By: Runrioter Wung <runrioter@qq.com> Co-Authored-By: Nate Fischer <nfischer@users.noreply.github.com>
grep
solution to fetch versionpackage.json
was hacky and wasn't always returning expected values. Now using other fallback methods to get version information, Following discussions from #439Changes
jq
with fallback topython
andnode
.undefined
frompackage.json
Fix #439
Close #552
Close #553