Skip to content

support "latest" to be specified as version for node and yarn#133

Merged
mikrostew merged 2 commits intovolta-cli:masterfrom
monshi:master
Aug 30, 2018
Merged

support "latest" to be specified as version for node and yarn#133
mikrostew merged 2 commits intovolta-cli:masterfrom
monshi:master

Conversation

@monshi
Copy link
Contributor

@monshi monshi commented Aug 25, 2018

notion will resolve to a version that is the latest released version of node/yarn
implemented latest for following notion commands:
notion fetch node latest
notion fetch yarn latest
notion install node latest
notion install yarn latest
notion use node latest
notion use yarn latest

moved node resolve request code out from resolve_public to a new method resolve_node_versions which can be reused for latest.
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 from https://nodejs.org/dist/index.json

notion will resolve to a version that is the latest released version of node/yarn
implemented for notion install/fetch/use will
Copy link
Contributor

@mikrostew mikrostew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Just a few comments around error handling

serial
}
}.into_index()?;
let index: Index = resolve_node_versions().unwrap().into_index()?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use a question mark here instead of unwrap(), so the error from resolve_node_versions is propagated correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 good to learning, updated the diff

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()?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, question mark instead of unwrap()

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)?;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! good call

Copy link
Contributor

@mikrostew mikrostew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, LGTM!

@mikrostew mikrostew merged commit b073719 into volta-cli:master Aug 30, 2018
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

Comments