-
Notifications
You must be signed in to change notification settings - Fork 285
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
Add support for imports
field in standalone files
#1789
Conversation
04e878a
to
4eda340
Compare
Looks like the snapshot failure is from the latest commit to main. |
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.
It feels like this is moving towards what we normally accomplish with DESCRIPTION. I end up wondering if we should lean into that, so we can use existing tooling for parsing this info.
I think what I'm literally suggesting is: perhaps we should use DCF for this frontmatter. That would make it easier to get the Imports info into desc and let it do the parsing, validating, etc. |
R/use-standalone.R
Outdated
@@ -42,10 +57,24 @@ use_standalone <- function(repo_spec, file = NULL, ref = NULL, host = NULL) { | |||
write_over(proj_path(dest_path), lines, overwrite = TRUE) | |||
|
|||
dependencies <- standalone_dependencies(lines, path) | |||
for (dependency in dependencies) { | |||
|
|||
for (dependency in dependencies$deps) { | |||
use_standalone(repo_spec, dependency) |
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'm noticing that we have a pre-existing problem with not passing along host
.
Should ref
propagate as well? I would think so.
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.
Now fixed.
Do we have any non-internal tools for parsing versions etc? I tried to find some but my research wasn't fruitful. I was planning to use DCF like this because I initially thought the desc package would help here, it looked like this: imports <- paste0("Imports: ", paste0(imports, collpase = ", "))
desc <- desc::desc(text = imports) But this didn't help much because I still needed to parse the versions after a Worth noting that DCF is less structured than yaml and doesn't have a standard way of specifying lists/vectors, sometimes it's just comma-separated text, sometimes it's in R code. |
I think this looks pretty promising: library(desc)
imports <- c(
"Imports:",
" cli (>= 3.0.1),",
" clipr (>= 0.3.0),",
" crayon"
)
d <- desc(text = imports)
d$get_deps()
#> type package version
#> 1 Imports cli >= 3.0.1
#> 2 Imports clipr >= 0.3.0
#> 3 Imports crayon * It seems desc is happy to operate on a DESCRIPTION fragment. Update: or is this what you meant? I.e. that we still have ">= 3.0.1" as the version. |
That's what I thought at first but I still needed to extract the comparison and the version. |
4eda340
to
e1976a2
Compare
I think the question of using DCF vs yaml is mosty orthogonal to this PR but here is a summary of my views:
|
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 added some documentation: basically taking info implicit in various parts of the PR and exposing it in the help.
It still seems like a lot of bespoke work to add this feature, but I guess it's just a fussy task.
This will pick up the new
imports:
field added in r-lib/rlang#1589 and ensure all dependencies are with sufficient versions are included inImports
.