Skip to content

Commit

Permalink
remove remaining layout check (#1109)
Browse files Browse the repository at this point in the history
fixes #1102
  • Loading branch information
aronatkins authored Oct 23, 2024
1 parent 61ad0e4 commit 666bb37
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 70 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
end-of-file extensions. Previously, a file with `.R` elsewhere in its name,
such as `.Rprofile`, was incorrectly considered. (#1106)

* Remove remaining directory layout validation check. (#1102)

* Use the public Connect server API endpoint `/v1/tasks/{id}` to poll task
progress. (#1088)

Expand Down
17 changes: 0 additions & 17 deletions R/appMetadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ appMetadata <- function(appDir,
isShinyappsServer = FALSE,
metadata = list()) {

checkAppLayout(appDir, appPrimaryDoc)

if (is_string(quarto)) {
lifecycle::deprecate_warn(
when = "1.0.0",
Expand Down Expand Up @@ -83,21 +81,6 @@ appMetadata <- function(appDir,
)
}

checkAppLayout <- function(appDir, appPrimaryDoc = NULL) {
appFilesBase <- tolower(list.files(appDir))
primaryIsRScript <- identical(tolower(tools::file_ext(appPrimaryDoc)), "r")

# check for single-file app collision
if (primaryIsRScript && "app.r" %in% appFilesBase) {
cli::cli_abort(
"Project must not contain both {.file app.R} and a single-file Shiny app."
)
}

# all other layouts are allowed; the server determines (with the required packages) if the content
# can be run/served.
}

# Infer the mode of the application from included files. Most content types
# only consider files at the directory root. TensorFlow saved models may be
# anywhere in the hierarchy.
Expand Down
8 changes: 0 additions & 8 deletions tests/testthat/_snaps/appMetadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@
Error in `appMetadata()`:
! `quarto` must be `TRUE`, `FALSE`, or `NA`, not the number 1.

# checkLayout() errors if primary doc & app.R

Code
checkAppLayout(dir, appPrimaryDoc = "myscript.R")
Condition
Error in `checkAppLayout()`:
! Project must not contain both 'app.R' and a single-file Shiny app.

# errors if no files with needed extension

Code
Expand Down
45 changes: 0 additions & 45 deletions tests/testthat/test-appMetadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,51 +65,6 @@ test_that("content type (appMode) is inferred and can be overridden", {

# checkLayout -------------------------------------------------------------

test_that("checkLayout() errors if primary doc & app.R", {
dir <- local_temp_app(list(
"app.R" = "",
"myscript.R" = ""
))

expect_snapshot(checkAppLayout(dir, appPrimaryDoc = "myscript.R"), error = TRUE)
})

test_that("checkLayout succeeds with some common app structures", {
rmd <- local_temp_app(list("foo.Rmd" = ""))
expect_no_error(checkAppLayout(rmd))

qmd <- local_temp_app(list("foo.qmd" = ""))
expect_no_error(checkAppLayout(qmd))

# perhaps script.R is a pre-render script that generates *.qmd
project <- local_temp_app(list("_quarto.yml" = "", "script.R" = ""))
expect_no_error(checkAppLayout(project))

md <- local_temp_app(list("_quarto.yml" = "", "index.md" = ""))
expect_no_error(checkAppLayout(md))

shiny1 <- local_temp_app(list("app.R" = ""))
expect_no_error(checkAppLayout(shiny1))

shiny2 <- local_temp_app(list("server.R" = "", "ui.R" = ""))
expect_no_error(checkAppLayout(shiny2))

api <- local_temp_app(list("plumber.R" = ""))
expect_no_error(checkAppLayout(api))

static <- local_temp_app(list("foo.html" = ""))
expect_no_error(checkAppLayout(static))

staticxml <- local_temp_app(list("data.xml" = ""))
expect_no_error(checkAppLayout(staticxml))

staticdata <- local_temp_app(list(
"data.txt" = "",
"cats.csv" = ""
))
expect_no_error(checkAppLayout(staticdata))
})

# inferAppMode ------------------------------------------------------------

test_that("can infer mode for API with plumber.R", {
Expand Down

0 comments on commit 666bb37

Please sign in to comment.