我正在为 AT/Bluesky 开发一个 R 包,我正在尝试一种非常规结构。由于 Bluesky 方法通过此处定义的 JSON 词典进行了非常精确的详细记录,我已将这些文件复制到 /inst 目录中,因此我的包结构如下所示:
├── DESCRIPTION
├── LICENSE
├── LICENSE.md
├── NAMESPACE
├── R
│ ├── bluesky.R
│ ├── helpers.R
│ ├── lexicon.R
│ └── types.R
├── README.Rmd
├── README.md
├── blueRsky.Rproj
├── inst
│ └── lexicons
│ ├── app
│ │ └── bsky
│ │ ├── actor
│ │ │ ├── defs.json
│ │ │ ├── getProfile.json
│ │ │ ├── getProfiles.json
│ │ │ ├── getSuggestions.json
│ │ │ ├── profile.json
│ │ │ ├── searchActors.json
│ │ │ └── searchActorsTypeahead.json
│ │ ├── embed
│ │ │ ├── external.json
│ │ │ ├── images.json
│ │ │ ├── record.json
│ │ │ └── recordWithMedia.json
│ │ ├── feed
│ │ │ ├── defs.json
│ │ │ ├── getAuthorFeed.json
│ │ │ ├── getLikes.json
│ │ │ ├── getPostThread.json
│ │ │ ├── getPosts.json
│ │ │ ├── getRepostedBy.json
│ │ │ ├── getTimeline.json
│ │ │ ├── like.json
│ │ │ ├── post.json
│ │ │ └── repost.json
│ │ ├── graph
│ │ │ ├── follow.json
│ │ │ ├── getFollowers.json
│ │ │ ├── getFollows.json
│ │ │ ├── getMutes.json
│ │ │ ├── muteActor.json
│ │ │ └── unmuteActor.json
│ │ ├── notification
│ │ │ ├── getUnreadCount.json
│ │ │ ├── listNotifications.json
│ │ │ └── updateSeen.json
│ │ ├── richtext
│ │ │ └── facet.json
│ │ └── unspecced
│ │ └── getPopular.json
│ └── com
├── man
│ ├── bsky_get_profile.Rd
│ ├── bsky_get_session.Rd
│ ├── bsky_get_timeline.Rd
│ └── bsky_search_actors.Rd
└── tests
├── testthat
│ └── test-lexicon.R
└── testthat.R
我有一些功能可以查找 Lexicon 模式,例如
load_schema <- function(id) {
loc <- c("lexicons", strsplit(id, "\\.")[[1]]) |>
paste0(collapse = "/") |>
paste0(".json")
file_path <- system.file(loc, package = "blueRsky", mustWork = FALSE)
cat("file_path:", file_path, "\n")
if (!file.exists(file_path)) {
stop(paste("Schema", id, "not found"))
}
jsonlite::read_json(system.file(loc, package = "blueRsky", mustWork = TRUE))
}
这非常好,因为它允许我抽象出很多用于构建请求的样板文件。
这在本地很好用,我可以安装这个包,我所有的测试都通过了,但是 R CMD CHECK 失败了。我相信原因是 R CMD CHECK 正在从 lexicons 目录中删除一些文件。输出说:
── R CMD build ──────────────────────────────────────────────────────────────────
✔ checking for file ‘/Users/colinfraser/projects/blueRsky/DESCRIPTION’ ...
─ preparing ‘blueRsky’: (1.1s)
✔ checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts (346ms)
─ checking for empty or unneeded directories
Removed empty directory ‘blueRsky/inst/lexicons/com’
─ building ‘blueRsky_0.0.0.9000.tar.gz’
删除了空目录‘blueRsky/inst/lexicons/com’.
那不好,因为实际上那个目录不是空的,它只是有嵌套的文件夹在里面。后来它失败了,因为它无法加载包代码。
我能做些什么来阻止 R CMD CHECK 删除这个文件吗?或者这里还有其他问题吗?我知道这是一个有点不寻常的包结构,但如果我能让它工作,它似乎会工作得很好。