-
Notifications
You must be signed in to change notification settings - Fork 15
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
Expose package version info #625
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,32 @@ | |
#' @export | ||
.ps.rpc.is_installed <- .ps.is_installed | ||
|
||
# Returns a list containing: | ||
# * the version string if the package is installed and NULL otherwise | ||
# * a minimum version to check for, with '0.0.0' as a dummy default | ||
# * a logical indicating if package is installed at or above the minimum version | ||
# This may seem weird, but it's impractical for positron-r to do version | ||
# comparisons. | ||
#' @export | ||
.ps.rpc.packageVersion <- function(pkg, checkAgainst = "0.0.0") { | ||
installed <- system.file(package = pkg) != "" | ||
|
||
if (installed) { | ||
version <- utils::packageVersion(pkg) | ||
list( | ||
version = as.character(version), | ||
checkAgainst = as.character(checkAgainst), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this argument returned to the caller? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it just felt convenient to package the version checked against and the result together? No more, no less. Maybe you're saying that either the returned info should be completist (include the package name) or be minimal (exclude the version checked against)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the idea is that the caller knows There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep exactly |
||
checkResult = version >= checkAgainst | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you move to list(version = version/NULL, compatible = TRUE/FALSE) So you end up with 3 states # Not installed (caller knows package name, for error reporting purposes)
list(version = NULL, compatible = FALSE)
# Not compatible (caller knows minimum version, for error reporting purposes)
list(version = version, compatible = FALSE)
# Good to go
list(version = version, compatible = TRUE) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, I'm trying to make argument names and shape match what's on the other side in positron-r. But I don't feel strongly and can just code around whatever form y'all want here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On quick glance it looks like In particular I find There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I'm changing it, just haven't pushed yet. Working on both ends. |
||
) | ||
} else { | ||
list( | ||
version = NULL, | ||
checkAgainst = as.character(checkAgainst), | ||
checkResult = FALSE | ||
) | ||
} | ||
} | ||
|
||
#' @export | ||
.ps.rpc.install_packages <- function(packages) { | ||
for (pkg in packages) { | ||
|
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.
I'd be tempted to call it this to be super clear that its:
I'd also be tempted to default it to
NULL
, implying "no minimum version check is done" - see alsorlang::is_installed()