File: plotlyjs.R

package info (click to toggle)
r-cran-plotly 4.9.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 26,616 kB
  • sloc: javascript: 137,775; sh: 20; makefile: 6
file content (56 lines) | stat: -rw-r--r-- 1,668 bytes parent folder | download
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
library(httr)
# download latest GitHub release
# for a particular version: `zip <- "https://github.com/plotly/plotly.js/archive/v1.33.1.zip"`
x <- httr::RETRY(
  verb = "GET",
  url = 'https://api.github.com/repos/plotly/plotly.js/releases/latest',
  times = 5,
  terminate_on = c(400, 401, 403, 404),
  terminate_on_success = TRUE
)
zip <- content(x)$zipball_url
tmp <- tempfile(fileext = ".zip")
download.file(zip, tmp)
unzip(tmp)

# update the default bundle
file.copy(
  Sys.glob("*plotly.js*/dist/plotly.min.js"), 
  "inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js", 
  overwrite = TRUE
)
# update the plotly.js LICENSE
file.copy(
  Sys.glob("*plotly.js*/LICENSE"), 
  "inst/htmlwidgets/lib/plotlyjs/LICENSE", 
  overwrite = TRUE
)
# update the locale files
locales <- Sys.glob("*plotly.js*/dist/plotly-locale-*.js")
file.copy(
  locales,
  file.path("inst/htmlwidgets/lib/plotlyjs/locales", sub("^plotly-locale-", "", basename(locales))),
  overwrite = TRUE
)
# update typed array polyfill
download.file(
  "https://raw.githubusercontent.com/plotly/plotly.js/master/dist/extras/typedarray.min.js",
  "inst/htmlwidgets/lib/typedarray/typedarray.min.js"
)

# update the plot schema
Schema <- jsonlite::fromJSON(Sys.glob("*plotly.js*/dist/plot-schema.json"))
usethis::use_data(Schema, overwrite = T, internal = T)

# clean-up and bump HTML dependency version
unlink("*plotly.js*", recursive = T)
message("Manually update plotly.R with this version")




# download latest build from master 
#download.file(
#  "https://raw.githubusercontent.com/plotly/plotly.js/master/dist/plotly.min.js", 
#  destfile = "inst/htmlwidgets/lib/plotlyjs/plotly-latest.min.js"
#)