support "latest" to be specified as version for node and yarn#133
Merged
mikrostew merged 2 commits intovolta-cli:masterfrom Aug 30, 2018
Merged
support "latest" to be specified as version for node and yarn#133mikrostew merged 2 commits intovolta-cli:masterfrom
mikrostew merged 2 commits intovolta-cli:masterfrom
Conversation
notion will resolve to a version that is the latest released version of node/yarn implemented for notion install/fetch/use will
mikrostew
suggested changes
Aug 28, 2018
Contributor
mikrostew
left a comment
There was a problem hiding this comment.
Nice! Just a few comments around error handling
crates/notion-core/src/catalog.rs
Outdated
| serial | ||
| } | ||
| }.into_index()?; | ||
| let index: Index = resolve_node_versions().unwrap().into_index()?; |
Contributor
There was a problem hiding this comment.
You should use a question mark here instead of unwrap(), so the error from resolve_node_versions is propagated correctly
Contributor
Author
There was a problem hiding this comment.
👍 good to learning, updated the diff
crates/notion-core/src/catalog.rs
Outdated
| pub fn parse_node_version(src: String) -> Fallible<String> { | ||
| let mut version:String= src; | ||
| if version == "latest" { | ||
| let index = resolve_node_versions().unwrap().into_index()?; |
Contributor
There was a problem hiding this comment.
Same here, question mark instead of unwrap()
crates/notion-core/src/catalog.rs
Outdated
| pub fn parse_yarn_version(src: String) -> Fallible<String> { | ||
| let mut version:String = src; | ||
| if version == "latest" { | ||
| let mut response: reqwest::Response = reqwest::get(PUBLIC_YARN_LATEST_VERSION).unwrap(); |
Contributor
There was a problem hiding this comment.
Need to handle this error, like how it's done in resolve_node_versions:
let mut response: reqwest::Response = reqwest::get(PUBLIC_YARN_LATEST_VERSION)
.with_context(RegistryFetchError::from_error)?;
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
notion will resolve to a version that is the latest released version of node/yarn
implemented latest for following notion commands:
notion fetch node latestnotion fetch yarn latestnotion install node latestnotion install yarn latestnotion use node latestnotion use yarn latestmoved node resolve request code out from
resolve_publicto a new methodresolve_node_versionswhich can be reused forlatest.Yarn has a API to simply fetch the latest version number
https://yarnpkg.com/latest-version, but couldn't find such endpoint for node, so ended up finding the latest version fromhttps://nodejs.org/dist/index.json