fix: корректная проверка схем

This commit is contained in:
2026-06-18 20:38:06 +03:00
parent 8f3343a103
commit dc51156490
2 changed files with 34 additions and 31 deletions

View File

@@ -1,15 +1,3 @@
.on_load = function(ns) {
check_and_init_scheme()
# set global settings:
set_global_options(
shiny.host = "0.0.0.0",
shiny.port = 1338,
APP.DEBUG = FALSE
)
}
#' @export
#' @description костыли для упрощения работы себе
@@ -18,23 +6,6 @@ set_global_options = function(
...
) {
config_params_to_check <- c(
"form_app_version",
"form_id",
"form_name",
"form_app_configure_path",
"form_auth_enabled",
"form_schemes"
)
expected_params_in_config <- config_params_to_check %in% names(config::get())
if (!all(expected_params_in_config)) {
cli::cli_abort(c(
"Необходимо добавить в файл конфига {.file config.yml} следующие параметры:",
paste0(config_params_to_check[!expected_params_in_config], ":")
))
}
options(
SYMBOL_DELIM = SYMBOL_DELIM,
...
@@ -55,6 +26,27 @@ ENABLED_SCHEMES <- stats::setNames(names(ENABLED_SCHEMES), ENABLED_SCHEMES)
#' @export
check_and_init_scheme = function() {
cli::cli_inform(c("*" = "проверка файла конфигурации..."))
config_params_to_check <- c(
"form_app_version",
"form_id",
"form_name",
"form_app_configure_path",
"form_auth_enabled",
"form_schemes"
)
expected_params_in_config <- config_params_to_check %in% names(config::get())
if (!all(expected_params_in_config)) {
cli::cli_abort(c(
"Необходимо добавить в файл конфига {.file config.yml} следующие параметры:",
paste0(config_params_to_check[!expected_params_in_config], ":")
))
}
# -------------------
cli::cli_inform(c("*" = "проверка схемы..."))
options(box.path = here::here())
@@ -84,13 +76,14 @@ check_and_init_scheme = function() {
db_files <- paste0(config::get("form_app_configure_path"), "/db/", scheme_names, ".sqlite")
if (!dir.exists("temp")) dir.create("temp")
hash_file <- "temp/schema_hash.rds"
#
exist_hash <- tools::md5sum(c(scheme_file, files_to_watch))
# если первый запуск (нет файла с кешем) инициализация схемы
if (!file.exists(hash_file) | !file.exists("temp/scheme.rds") | !all(file.exists(db_files))) {
if (!file.exists(hash_file) | !file.exists("temp/scheme.rds")) {
init_scheme(scheme_file)

10
app.R
View File

@@ -19,9 +19,19 @@ box::use(
# глобальные переменные и проверка/инициация схемы:
box::use(
R/modules/global_options[set_global_options, check_and_init_scheme],
R/modules/global_options[AUTH_ENABLED, ENABLED_SCHEMES],
)
# set global settings:
set_global_options(
shiny.host = "0.0.0.0",
# shiny.port = 1338,
APP.DEBUG = FALSE
)
check_and_init_scheme()
SCHMS <- readRDS("temp/scheme.rds")
# CHECK FOR PANDOC ----------