1#
2# regenerate-css.R
3#
4# Copyright (C) 2021 by RStudio, PBC
5#
6# Unless you have received this program directly from RStudio pursuant
7# to the terms of a commercial license agreement with RStudio, then
8# this program is licensed to you under the terms of version 3 of the
9# GNU Affero General Public License. This program is distributed WITHOUT
10# ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
11# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
12# AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
13#
14
15# Manual helper for updating expected CSS values for tmTheme conversion.
16#
17# Preconditions:
18#
19# 1. "themes" object in environment from test-themes.R
20# 2. Working directory set to "testthat"
21#
22
23units <- as.integer(length(themes))
24job <- rstudioapi::jobAdd("Update themes",
25                          progressUnits = units,
26                          running = TRUE,
27                          autoRemove = FALSE)
28
29.rs.enumerate(themes, function(key, value) {
30  tryCatch({
31     rstudioapi::jobAddOutput(job, paste0(key, "... "))
32     converted <- .rs.convertTmTheme(
33        .rs.parseTmTheme(
34           file.path(
35              "themes",
36              "tmThemes",
37              paste0(key, ".tmTheme"))))
38     rstudioapi::jobSetStatus(job, key)
39     writeLines(converted$theme,
40                file.path("themes", "acecss", paste0(value$fileName, ".css")))
41     rstheme <- .rs.convertAceTheme(key, converted$theme, value$isDark)
42     writeLines(rstheme, file.path("themes", "rsthemes", paste0(value$fileName, ".rstheme")))
43     rstudioapi::jobAddOutput(job, "OK\n")
44     rstudioapi::jobAddProgress(job, 1)
45  }, error = function(e) {
46    rstudioapi::jobSetState(job, "failed")
47    stop(e)
48  })
49})
50
51rstudioapi::jobSetState(job, "succeeded")
52