The goal of pkgfiles is to enumerate and classify all files in an R package project. This is mostly useful for other packages that iterate over all files of a specific kind in an R package.
Once released, you can install the released version of pkgfiles from CRAN with:
For now, install from GitHub with
The pf_get()
function enumerates and classifies all files in the current project.
library(pkgfiles)
pf_get()
#> ✔ Setting active project to '/home/travis/build/krlmlr/pkgfiles'
#> ● 4 R source
#> ● 1 DESCRIPTION
#> ● 1 NEWS
#> ● 1 RStudio project
#> ● 1 Documentation
#> ● 1 NAMESPACE
#> ● 3 CI configuration
#> ● 2 README
#> ● 1 Build-ignore configuration
#> ● 1 Git-ignore configuration
#> ● 32 Git internal
#> ● 38 Other: docs/.git/FETCH_HEAD, docs/.git/HEAD, docs/.git/config, docs/.git/description, docs/.git/hooks/README.sample, …
Under the hood, the returned object is a tibble that contains the return from a fs::dir_info()
call augmented by a class
column:
tibble::as_tibble(pf_get())
#> # A tibble: 86 x 19
#> path type size permissions modification_time user group
#> <fs::path> <fct> <fs::b> <fs::perms> <dttm> <chr> <chr>
#> 1 .Rbuildig… file 89 rw-rw-r-- 2019-05-20 14:24:56 trav… trav…
#> 2 .git/HEAD file 41 rw-rw-r-- 2019-05-20 14:24:56 trav… trav…
#> 3 .git/ORIG… file 41 rw-rw-r-- 2019-05-20 14:25:32 trav… trav…
#> 4 .git/conf… file 273 rw-rw-r-- 2019-05-20 14:24:56 trav… trav…
#> 5 .git/desc… file 73 rw-rw-r-- 2019-05-20 14:24:56 trav… trav…
#> 6 .git/hook… file 478 rwxrwxr-x 2019-05-20 14:24:56 trav… trav…
#> 7 .git/hook… file 896 rwxrwxr-x 2019-05-20 14:24:56 trav… trav…
#> 8 .git/hook… file 3.25K rwxrwxr-x 2019-05-20 14:24:56 trav… trav…
#> 9 .git/hook… file 189 rwxrwxr-x 2019-05-20 14:24:56 trav… trav…
#> 10 .git/hook… file 424 rwxrwxr-x 2019-05-20 14:24:56 trav… trav…
#> # … with 76 more rows, and 12 more variables: device_id <dbl>,
#> # hard_links <dbl>, special_device_id <dbl>, inode <dbl>,
#> # block_size <dbl>, blocks <dbl>, flags <int>, generation <dbl>,
#> # access_time <dttm>, change_time <dttm>, birth_time <dttm>, class <chr>
The classification is based on regular expressions for the project-relative path of the files. This list is extensible but the existing entries should rarely change.
pkgfiles:::classification
#> # A tibble: 33 x 3
#> class regex desc
#> <chr> <chr> <chr>
#> 1 R "^R/(?:[^/])+\\.[rR]$" R source
#> 2 R/unix "^R/unix/(?:[^/])+\\.[rR]$" R source (Unix only)
#> 3 R/windows "^R/windows/(?:[^/])+\\.[rR… R source (Windows only)
#> 4 DESCRIPTION ^DESCRIPTION$ DESCRIPTION
#> 5 NEWS "^(?:NEWS|NEWS\\.md|ChangeL… NEWS
#> 6 Rproj ^.*[.]Rproj$ RStudio project
#> 7 man "^man/(?:[^/])+\\.Rd$" Documentation
#> 8 man/unix "^man/unix/(?:[^/])+\\.Rd$" Documentation (Unix only)
#> 9 man/windows "^man/windows/(?:[^/])+\\.R… Documentation (Windows o…
#> 10 vignettes/text/R… "^vignettes/(?:[^/])+\\.Rmd… Vignette (Rmd sources)
#> # … with 23 more rows