Closed alandipert closed 4 years ago
Note that the lack of this in usethis would be mitigated by forthcoming "Shiny app scaffold/template" feature that @wch is working on very soon.
Would you consider requiring a DESCRIPTION for shiny apps in this situation?
I am, though I think we would still need an additional convention to declare the app entrypoint file/function(s). The golem package is a related work that suggests a DESCRIPTION file along with a convention for naming entrypoint files: https://thinkr-open.github.io/building-shiny-apps-workflow/golem.html#understanding-golem-app-structure
~~ 2 minutes elapse ~~
On further reflection the DESCRIPTION/golem way and the autoload way maybe aren't mutually exclusive? I'll have to think about this more but I'd love to hear other thoughts.
I was sort of imagining that this could be a "partial" package so that app.R
would still live in the root directory (although maybe that would be too confusing)
OTOH, we could just make use_test()
work outside of a package — it would just require a couple of conditional to avoid touching the DESCRIPTION if it doesn't exist.
@hadley thanks, I like that suggestion about making use_test()
more flexible, would you care for a PR? I could give it a whirl tomorrow.
Yeah, that’d be great
In the next version of Shiny we're planning on releasing a new function for running tests in the application environment,
shiny::runTests()
https://github.com/rstudio/shiny/pull/2585This will promote the use of
testthat
in Shiny apps.I thought to start a discussion here on
usethis::use_testthat()
's behavior with respect to this change. Currently, running it in a Shiny app results in the following error message:We hope to promote unit testing in Shiny apps moving forward, and I thought it might be good for
use_testthat()
to work in this case.Unfortunately, Shiny doesn't have a predicate function to determine whether or not the current directory is plausibly a Shiny app. However, I think the logic's pretty simple: at a minimum, there has to be either an
app.R
or both aserver.R
andui.R
in the current directory.So, one way forward would be to check for package and Shiny app plausibility, and bail otherwise, but as a non-expert on all things
usethis
I'm looking forward to hearing how other people think it should work.Thanks in advance for your feedback, and consider me on the hook for whatever implementation is needed 👍