Skip to content

Commit 0de486b

Browse files
authored
Merge pull request #227 from ThinkR-open/v0.5.2-before-cran
V0.5.2 before cran
2 parents 7271887 + a84d693 commit 0de486b

19 files changed

+66
-70
lines changed

DESCRIPTION

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: fusen
22
Title: Build a Package from Rmarkdown Files
3-
Version: 0.5.1
3+
Version: 0.5.2
44
Authors@R: c(
55
person("Sebastien", "Rochette", , "[email protected]", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0002-1565-9313")),
@@ -47,10 +47,10 @@ Suggests:
4747
withr
4848
VignetteBuilder:
4949
knitr
50-
Config/fusen/version: 0.5.1
50+
Config/fusen/version: 0.5.2
5151
Config/Needs/website: ThinkR-open/thinkrtemplate
5252
Config/testthat/edition: 3
53-
Config/testthat/parallel: true
53+
Config/testthat/parallel: false
5454
Encoding: UTF-8
5555
Language: en-US
5656
LazyData: true

R/add_flat_template.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ create_fusen_choices <- c("full", "minimal", "teaching", "dev_history")
129129
#'
130130
#' @examples
131131
#' # Create a new project
132-
#' dummypackage <- tempfile("dummypackage")
132+
#' dummypackage <- tempfile("dummy.package.flat")
133133
#' dir.create(dummypackage)
134134
#'
135135
#' # Add

R/create_fusen_rsproject.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ create_fusen_gui <- function(path,
125125
flat_name = template,
126126
with_git) {
127127
create_fusen(
128-
path = file.path(getwd(), path),
128+
path = file.path(normalize_path_winslash(getwd()), path),
129129
template = template,
130130
flat_name = flat_name,
131131
open = FALSE, # Project opening is done spontaneously by Rstudio Project Wizard

R/fill_description.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#'
1313
#' @examples
1414
#' # Create a new project
15-
#' dummypackage <- tempfile("dummypackage")
15+
#' dummypackage <- tempfile("dummy.package.desc")
1616
#' dir.create(dummypackage)
1717
#'
1818
#' fill_description(

R/inflate.R

+14-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ regex_example <- paste(regex_example_vec, collapse = "|")
4242
#'
4343
#' @examples
4444
#' # Create a new project
45-
#' dummypackage <- tempfile("dummypackage")
45+
#' dummypackage <- tempfile("dummy.package")
4646
#' dir.create(dummypackage)
4747
#'
4848
#' # {fusen} steps
@@ -127,11 +127,21 @@ inflate <- function(pkg = ".", flat_file,
127127
}
128128

129129
old <- setwd(pkg)
130-
on.exit(setwd(old))
130+
if (normalizePath(old, mustWork = FALSE) != normalizePath(pkg, mustWork = FALSE)) {
131+
if (dir.exists(old)) {
132+
on.exit(setwd(old))
133+
} else {
134+
on.exit(here::here())
135+
}
136+
}
131137

132138
old_proj <- usethis::proj_get()
133-
if (normalizePath(old_proj) != normalizePath(pkg)) {
134-
on.exit(usethis::proj_set(old_proj))
139+
if (normalizePath(old_proj, mustWork = FALSE) != normalizePath(pkg, mustWork = FALSE)) {
140+
if (dir.exists(old_proj)) {
141+
on.exit(usethis::proj_set(old_proj))
142+
} else {
143+
on.exit(usethis::proj_set(here::here()))
144+
}
135145
usethis::proj_set(pkg)
136146
}
137147

R/inflate_all.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#'
4141
#' # You can also inflate_all flats of another package as follows
4242
#' # Example with a dummy package with a flat file
43-
#' dummypackage <- tempfile("inflateall")
43+
#' dummypackage <- tempfile("inflateall.otherpkg")
4444
#' dir.create(dummypackage)
4545
#' fill_description(pkg = dummypackage, fields = list(Title = "Dummy Package"))
4646
#' flat_files <- add_minimal_package(

R/register_config_file.R

+10-7
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#' })
5959
#' unlink(dummypackage, recursive = TRUE)
6060
check_not_registered_files <- function(path = ".", guess = TRUE, to_csv = TRUE, open = FALSE) {
61-
path <- normalizePath(path, winslash = "/")
61+
path <- normalize_path_winslash(path)
6262

6363
all_r <- list.files(file.path(path, "R"), pattern = "[.]R$|[.]r$", full.names = TRUE)
6464
all_test <- list.files(file.path(path, "tests", "testthat"), pattern = "[.]R$|[.]r$", full.names = TRUE)
@@ -86,7 +86,7 @@ check_not_registered_files <- function(path = ".", guess = TRUE, to_csv = TRUE,
8686
if (file.exists(config_file)) {
8787
# Read config file, and remove those already there
8888
config_list <- yaml::read_yaml(config_file)
89-
config_list_path <- normalizePath(get_list_paths(config_list), mustWork = FALSE, winslash = "/")
89+
config_list_path <- normalize_path_winslash(get_list_paths(config_list), mustWork = FALSE)
9090
res_existing <- res[res$path %in% config_list_path, ]
9191
res_new <- res[!res$path %in% config_list_path, ]
9292
config_flat_paths <- sapply(config_list, function(x) x[["path"]])
@@ -121,11 +121,11 @@ check_not_registered_files <- function(path = ".", guess = TRUE, to_csv = TRUE,
121121
}
122122

123123
# TODO go back to relative path
124-
res_new$path <- gsub(paste0(getwd(), "/"), "", normalize_path_winslash(res_new$path, mustWork = TRUE), fixed = TRUE)
124+
res_new$path <- gsub(paste0(normalize_path_winslash(getwd()), "/"), "", normalize_path_winslash(res_new$path, mustWork = TRUE), fixed = TRUE)
125125

126126
# config_file may not exist already
127127
csv_file <- file.path(
128-
gsub(paste0(getwd(), "/"), "", dirname(normalize_path_winslash(config_file, mustWork = FALSE)), fixed = TRUE), "config_not_registered.csv"
128+
gsub(paste0(normalize_path_winslash(getwd()), "/"), "", dirname(normalize_path_winslash(config_file, mustWork = FALSE)), fixed = TRUE), "config_not_registered.csv"
129129
)
130130

131131
# Save for manual modification
@@ -174,9 +174,12 @@ guess_flat_origin <- function(path) {
174174
lines[grep("(G|g)enerated by \\{fusen\\} from", lines)][1]
175175
)
176176

177-
guess_path <- normalizePath(guess_path, mustWork = FALSE, winslash = "/")
177+
guess_path <- normalize_path_winslash(guess_path, mustWork = FALSE)
178178
if (file.exists(guess_path)) {
179-
guess_path <- gsub(paste0(getwd(), "/"), "", normalizePath(guess_path, mustWork = FALSE, winslash = "/"))
179+
guess_path <- gsub(
180+
paste0(normalize_path_winslash(getwd()), "/"), "",
181+
normalize_path_winslash(guess_path, mustWork = FALSE)
182+
)
180183
return(guess_path)
181184
} else {
182185
return("No existing source path found.")
@@ -638,7 +641,7 @@ register_all_to_config <- function(pkg = ".") {
638641

639642
# Delete out_df
640643
csv_file <- file.path(
641-
gsub(paste0(getwd(), "/"), "", dirname(normalize_path_winslash(config_file, mustWork = FALSE)), fixed = TRUE), "config_not_registered.csv"
644+
gsub(paste0(normalize_path_winslash(getwd()), "/"), "", dirname(normalize_path_winslash(config_file, mustWork = FALSE)), fixed = TRUE), "config_not_registered.csv"
642645
)
643646
if (file.exists(csv_file)) {
644647
cli::cat_rule(paste("Delete", csv_file))

dev/dev_history.R

+5-27
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ testthat::test_file("tests/testthat/test-add_flat_template.R")
194194
testthat::test_file("tests/testthat/test-skeleton.R")
195195
Sys.setenv("NOT_CRAN" = "false")
196196

197+
# Run line by line
197198
Sys.setenv("FUSEN_TEST_PUBLISH" = "TRUE")
198199
testthat::test_file("tests/testthat/test-init_share_on_github.R")
199200
Sys.setenv("FUSEN_TEST_PUBLISH" = "FALSE")
@@ -206,32 +207,6 @@ Sys.setenv("FUSEN_TEST_PUBLISH" = "FALSE")
206207
# Run examples in interactive mode too
207208
devtools::run_examples()
208209

209-
local <- utils::fileSnapshot(".", timestamp = tempfile("timestamp"), md5sum = TRUE)
210-
home <- utils::fileSnapshot("~", timestamp = tempfile("timestamp"), md5sum = TRUE)
211-
212-
# run tests or whatever, then ...
213-
# x <- autotest::autotest_package(test = TRUE)
214-
devtools::test()
215-
devtools::run_examples()
216-
# vignettes
217-
dircheck <- tempfile("check")
218-
dir.create(dircheck)
219-
rcmdcheck::rcmdcheck(check_dir = dircheck)
220-
# browseURL(dircheck)
221-
222-
the_dir <- list.files(file.path(dircheck), pattern = ".Rcheck", full.names = TRUE)
223-
# Same tests, no new files
224-
all(list.files(file.path(the_dir, "tests", "testthat")) %in%
225-
list.files(file.path(".", "tests", "testthat")))
226-
227-
devtools::build_vignettes()
228-
devtools::clean_vignettes()
229-
230-
utils::changedFiles(local, md5sum = TRUE)
231-
utils::changedFiles(home, md5sum = TRUE)
232-
233-
DT::datatable(x)
234-
235210
# Check package as CRAN
236211
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"))
237212
devtools::check(args = c("--no-manual", "--as-cran"))
@@ -240,9 +215,12 @@ devtools::check(args = c("--no-manual", "--as-cran"))
240215
# remotes::install_github("ThinkR-open/checkhelper")
241216
tags <- checkhelper::find_missing_tags()
242217
View(tags$functions)
218+
219+
# Remettre: Config/testthat/parallel: false dans DESCRIPTION
243220
out <- checkhelper::check_clean_userspace(pkg = ".")
244221
out
245222
checkhelper::check_as_cran()
223+
# Remettre: Config/testthat/parallel: true dans DESCRIPTION
246224

247225
# Check spelling
248226
# usethis::use_spell_check()
@@ -260,7 +238,7 @@ usethis::use_version(which = c("patch", "minor", "major", "dev")[2])
260238
# _rhub
261239
devtools::check_rhub()
262240
rhub::platforms()
263-
rhub::check_on_windows(check_args = "--force-multiarch")
241+
rhub::check_on_windows(check_args = "--force-multiarch", show_status = FALSE)
264242
rhub::check_on_solaris(show_status = FALSE)
265243
rhub::check(platform = "debian-clang-devel", show_status = FALSE)
266244
rhub::check(platform = "debian-gcc-devel", show_status = FALSE)

dev/flat_create_flat.Rmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ local_file_ignore <- function(file, ignores) {
249249

250250
```{r examples-1}
251251
# Create a new project
252-
dummypackage <- tempfile("dummypackage")
252+
dummypackage <- tempfile("dummy.package.flat")
253253
dir.create(dummypackage)
254254
255255
# Add
@@ -461,7 +461,7 @@ for (template in all_templates) {
461461
main_flat_file_name <- "teaching"
462462
}
463463
464-
dummypackage4 <- tempfile(pattern = "all.templates.knit")
464+
dummypackage4 <- tempfile(pattern = paste0("all.templates.knit", gsub("_", ".", template)))
465465
dir.create(dummypackage4)
466466
467467
orig.proj <- here::here()

dev/flat_inflate_all.Rmd

+4-4
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ inflate_all(stylers = styler::style_pkg)
194194
195195
# You can also inflate_all flats of another package as follows
196196
# Example with a dummy package with a flat file
197-
dummypackage <- tempfile("inflateall")
197+
dummypackage <- tempfile("inflateall.otherpkg")
198198
dir.create(dummypackage)
199199
fill_description(pkg = dummypackage, fields = list(Title = "Dummy Package"))
200200
flat_files <- add_minimal_package(
@@ -241,7 +241,7 @@ unlink(dummypackage, recursive = TRUE)
241241

242242
```{r tests-inflate_all}
243243
# unlink(dummypackage, recursive = TRUE)
244-
dummypackage <- tempfile("inflateall")
244+
dummypackage <- tempfile("inflateall.first")
245245
dir.create(dummypackage)
246246
fill_description(pkg = dummypackage, fields = list(Title = "Dummy Package"))
247247
dev_file <- suppressMessages(add_minimal_package(pkg = dummypackage, overwrite = TRUE, open = FALSE))
@@ -484,7 +484,7 @@ unlink(dummypackage, recursive = TRUE)
484484
485485
# You can also inflate_all flats of another package as follows
486486
# Example with a dummy package with a flat file
487-
dummypackage <- tempfile("inflateall")
487+
dummypackage <- tempfile("inflateall.other.pkg")
488488
dir.create(dummypackage)
489489
suppressMessages(fill_description(pkg = dummypackage, fields = list(Title = "Dummy Package")))
490490
flat_files <- add_minimal_package(
@@ -540,7 +540,7 @@ usethis::with_project(dummypackage, {
540540
unlink(dummypackage, recursive = TRUE)
541541
542542
# Test inflate_all_no_check vs inflate_all with check ----
543-
dummypackage <- tempfile("inflateall")
543+
dummypackage <- tempfile("inflateall.nocheck")
544544
dir.create(dummypackage)
545545
suppressMessages(fill_description(pkg = dummypackage, fields = list(Title = "Dummy Package")))
546546
dev_file <- suppressMessages(add_minimal_package(pkg = dummypackage, overwrite = TRUE, open = FALSE))

dev/flat_register_config_file.Rmd

+10-7
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Have a look at the configuration file at the end of the process to check that ev
154154
#'
155155
#' @export
156156
check_not_registered_files <- function(path = ".", guess = TRUE, to_csv = TRUE, open = FALSE) {
157-
path <- normalizePath(path, winslash = "/")
157+
path <- normalize_path_winslash(path)
158158

159159
all_r <- list.files(file.path(path, "R"), pattern = "[.]R$|[.]r$", full.names = TRUE)
160160
all_test <- list.files(file.path(path, "tests", "testthat"), pattern = "[.]R$|[.]r$", full.names = TRUE)
@@ -182,7 +182,7 @@ check_not_registered_files <- function(path = ".", guess = TRUE, to_csv = TRUE,
182182
if (file.exists(config_file)) {
183183
# Read config file, and remove those already there
184184
config_list <- yaml::read_yaml(config_file)
185-
config_list_path <- normalizePath(get_list_paths(config_list), mustWork = FALSE, winslash = "/")
185+
config_list_path <- normalize_path_winslash(get_list_paths(config_list), mustWork = FALSE)
186186
res_existing <- res[res$path %in% config_list_path, ]
187187
res_new <- res[!res$path %in% config_list_path, ]
188188
config_flat_paths <- sapply(config_list, function(x) x[["path"]])
@@ -217,11 +217,11 @@ check_not_registered_files <- function(path = ".", guess = TRUE, to_csv = TRUE,
217217
}
218218

219219
# TODO go back to relative path
220-
res_new$path <- gsub(paste0(getwd(), "/"), "", normalize_path_winslash(res_new$path, mustWork = TRUE), fixed = TRUE)
220+
res_new$path <- gsub(paste0(normalize_path_winslash(getwd()), "/"), "", normalize_path_winslash(res_new$path, mustWork = TRUE), fixed = TRUE)
221221

222222
# config_file may not exist already
223223
csv_file <- file.path(
224-
gsub(paste0(getwd(), "/"), "", dirname(normalize_path_winslash(config_file, mustWork = FALSE)), fixed = TRUE), "config_not_registered.csv"
224+
gsub(paste0(normalize_path_winslash(getwd()), "/"), "", dirname(normalize_path_winslash(config_file, mustWork = FALSE)), fixed = TRUE), "config_not_registered.csv"
225225
)
226226

227227
# Save for manual modification
@@ -270,9 +270,12 @@ guess_flat_origin <- function(path) {
270270
lines[grep("(G|g)enerated by \\{fusen\\} from", lines)][1]
271271
)
272272

273-
guess_path <- normalizePath(guess_path, mustWork = FALSE, winslash = "/")
273+
guess_path <- normalize_path_winslash(guess_path, mustWork = FALSE)
274274
if (file.exists(guess_path)) {
275-
guess_path <- gsub(paste0(getwd(), "/"), "", normalizePath(guess_path, mustWork = FALSE, winslash = "/"))
275+
guess_path <- gsub(
276+
paste0(normalize_path_winslash(getwd()), "/"), "",
277+
normalize_path_winslash(guess_path, mustWork = FALSE)
278+
)
276279
return(guess_path)
277280
} else {
278281
return("No existing source path found.")
@@ -521,7 +524,7 @@ register_all_to_config <- function(pkg = ".") {
521524
522525
# Delete out_df
523526
csv_file <- file.path(
524-
gsub(paste0(getwd(), "/"), "", dirname(normalize_path_winslash(config_file, mustWork = FALSE)), fixed = TRUE), "config_not_registered.csv"
527+
gsub(paste0(normalize_path_winslash(getwd()), "/"), "", dirname(normalize_path_winslash(config_file, mustWork = FALSE)), fixed = TRUE), "config_not_registered.csv"
525528
)
526529
if (file.exists(csv_file)) {
527530
cli::cat_rule(paste("Delete", csv_file))

man/add_flat_template.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/fill_description.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/inflate.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/inflate_all.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-add_flat_template.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ for (template in all_templates) {
182182
main_flat_file_name <- "teaching"
183183
}
184184

185-
dummypackage4 <- tempfile(pattern = "all.templates.knit")
185+
dummypackage4 <- tempfile(pattern = paste0("all.templates.knit", gsub("_", ".", template)))
186186
dir.create(dummypackage4)
187187

188188
orig.proj <- here::here()

tests/testthat/test-inflate-part2.R

+5-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ unlink(dummypackage, recursive = TRUE)
5353
alltemp <- tempfile("all.templates.inflate")
5454
dir.create(alltemp)
5555

56-
# for (pkgname in c("full", "teaching", "minimal")) {
5756
create_choices_test <- fusen:::create_fusen_choices[!grepl("dev_history", fusen:::create_fusen_choices)]
5857
for (pkgname in create_choices_test) {
58+
# pkgname <- create_choices_test[1]
5959
# No "additional" with create_fusen
6060
# {fusen} steps
6161
path_foosen <- normalize_path_winslash(file.path(alltemp, pkgname), mustWork = FALSE)
@@ -64,7 +64,7 @@ for (pkgname in create_choices_test) {
6464

6565
usethis::with_project(path_foosen, {
6666
fill_description(pkg = path_foosen, fields = list(Title = "Dummy Package"))
67-
usethis::use_gpl_license()
67+
suppressMessages(usethis::use_gpl_license())
6868

6969
test_that("description is good", {
7070
expect_true(file.exists(file.path(path_foosen, "DESCRIPTION")))
@@ -154,7 +154,9 @@ for (pkgname in create_choices_test) {
154154
skip_if_not(interactive())
155155
# Needs MASS, lattice, Matrix installed
156156
# quiet and checkdir
157-
checkdir <- file.path(alltemp, paste0("checkout", pkgname))
157+
checkdir <- normalize_path_winslash(
158+
file.path(alltemp, paste0("checkout", pkgname)),
159+
mustWork = FALSE)
158160
extra_params <- glue(
159161
'fusen::inflate(pkg = "{path_foosen}",
160162
check = TRUE, check_dir = "{checkdir}",

0 commit comments

Comments
 (0)