-
Notifications
You must be signed in to change notification settings - Fork 83
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
Standardize single doc deployment #698
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4a3ab1c
WIP
hadley ac16ca5
Merged origin/main into standardizeSingleDocDeployment
hadley 0dfd019
Tweak docs
hadley 6115e92
Move normalizePath up
hadley 7eee364
Fix (hopefully!) failing test on windows
hadley 7c8633b
Normalize path in function too
hadley 867a735
Merge commit 'e1f5511e3459cc3b9a300cbb36561ed4e88f7a88'
hadley eabc560
Fix merge failure
hadley d046883
Merge commit '4c3bb2393860d43d492f9161448efc5166378df1'
hadley 72b1beb
Deprecate use of individual static files in appDir
hadley b2641a3
Restore missing sentence
hadley de9fd39
Maybe dirname de-normalises?
hadley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# deployDoc correctly reports bad path | ||
|
||
Code | ||
deployDoc("doesntexist.Rmd") | ||
Condition | ||
Error in `deployDoc()`: | ||
! `doc`, "doesntexist.Rmd", does not exist. | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
test_that("deployDoc correctly reports bad path", { | ||
expect_snapshot(deployDoc("doesntexist.Rmd"), error = TRUE) | ||
}) | ||
|
||
# standardizeSingleDocDeployment ------------------------------------------ | ||
|
||
test_that("turns appDir into appDir + appPrimarySourceDoc", { | ||
dir <- local_temp_app(list("foo.R" = "")) | ||
|
||
doc <- standardizeSingleDocDeployment(file.path(dir, "foo.R")) | ||
expect_equal(doc$appDir, normalizePath(dir)) | ||
expect_equal(doc$appPrimaryDoc, "foo.R") | ||
}) | ||
|
||
test_that("shiny rmd deploys whole directory", { | ||
dir <- local_temp_app(list("foo.Rmd" = c( | ||
"---", | ||
"runtime: shiny", | ||
"---" | ||
))) | ||
doc <- standardizeSingleDocDeployment(file.path(dir, "foo.Rmd")) | ||
expect_equal(doc$appFiles, NULL) | ||
}) | ||
|
||
test_that("regular rmd deploys file and dependencies", { | ||
dir <- local_temp_app(list( | ||
"foo.Rmd" = c( | ||
"---", | ||
"resource_files: [foo.csv]", | ||
"---" | ||
), | ||
"foo.csv" = "" | ||
)) | ||
|
||
doc <- standardizeSingleDocDeployment(file.path(dir, "foo.Rmd"), quiet = TRUE) | ||
expect_equal(doc$appFiles, c("foo.Rmd", "foo.csv")) | ||
}) | ||
|
||
test_that("other types deploy that one file", { | ||
dir <- local_temp_app(list("foo.R" = "")) | ||
doc <- standardizeSingleDocDeployment(file.path(dir, "foo.R")) | ||
expect_equal(doc$appFiles, "foo.R") | ||
}) |
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.
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.
One thing that's slightly unappealing about this approach is that we use a different approach to determining
appFiles
depending on whether you dodeployApp("foo.Rmd")
ordeployApp(appPrimaryDoc = "foo.Rmd")
. An alternative approach would be to add anappPrimaryDoc
argument toappStandardizeFiles()
and callrmarkdown::find_external_dependencies()
there whenappPrimaryDoc
is supplied.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.
Another approach, since this never appears to have been documented, would be to deprecate this use
appDir
and tell folks to calldeployDoc()
instead.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.
Interesting. I forgot about this difference.
The existing
deployApp("foo.Rmd")
feels like a convenience, but we should nudge folks towards usingdeployDoc
should they provide a file.Added in: #16, and before the notion of a "primary doc".
I'm uneasy about the automatic use of
rmarkdown::find_external_dependencies
. On the one hand, it does feel like it will produce the set of files that most folks want to include -- directory explosion is often too greedy. On the other hand, its use would add to the "magic" that happens in the "lower-level"deployApp
. Its inclusion could suddenly force more folks to compute their ownappFiles
.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.
Deprecating the
deployApp -> deployDoc -> deployApp
workflow feels like the right path.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.
Yeah, I think the fundamentally different mechanism of file discovery suggests that this is a
deployDoc()
feature, and we should deprecate this old path.