-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprefs_rstudio.R
58 lines (48 loc) · 1.53 KB
/
prefs_rstudio.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
pkgload::load_all(here::here())
library(purrr)
tags_gh <- gh::gh(
"/repos/rstudio/rstudio/git/refs/tags"
)
tags <-
tags_gh %>%
map_dfr(~ list(
tag = .x$ref,
sha = .x$object$sha %||% NA_character_,
tag_url = .x$url
))
# tags are released versions of RStudio IDE
# the prefs schema json was added in 1.3
tags <- tags[tags$tag >= "refs/tags/v1.3", ]
tags_names <- sub("refs/tags/v?", "", tags$tag)
tags_ref <- c(set_names(tags$tag, tags_names), latest = "main")
revisions <- map(tags_ref, function(ref) {
gh::gh(
"/repos/rstudio/rstudio/contents/{file_path}",
file_path = "src/cpp/session/resources/schema/user-prefs-schema.json",
ref = ref
)
})
versions <- revisions %>% map_dfr(`[`, "content", .id = "ref")
versions$digest <- map_chr(versions$content, digest::digest)
versions <- versions[!duplicated(versions$digest) | versions$ref == "latest", ]
rstudio_prefs <-
versions[c("content", "ref")] %>%
reduce(set_names) %>%
map(function(content) {
content <- base64enc::base64decode(content)
content <- rawToChar(content)
prefs_schema_prepare(content)
})
# Write a JSON version of prefs for better diffs
jsonlite::write_json(
rstudio_prefs,
here::here("data-raw/rstudio_prefs.json"),
pretty = TRUE,
auto_unbox = TRUE,
null = "null",
force = TRUE
)
prefs_rstudio_v <- rstudio_prefs[setdiff(names(rstudio_prefs), "latest")]
prefs_rstudio <- rstudio_prefs$latest
saveRDS(prefs_rstudio, here::here("inst", "prefs_rstudio.rds"), version = 3)
usethis::use_data(prefs_rstudio_v, overwrite = TRUE)