From dc511564905e26accd585032feae2a835ff66522 Mon Sep 17 00:00:00 2001 From: madeliri Date: Thu, 18 Jun 2026 20:38:06 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=BD=D0=B0=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=81=D1=85=D0=B5=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- R/modules/global_options.R | 55 +++++++++++++++++--------------------- app.R | 10 +++++++ 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/R/modules/global_options.R b/R/modules/global_options.R index cf18b86..8cf2525 100644 --- a/R/modules/global_options.R +++ b/R/modules/global_options.R @@ -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 костыли для упрощения работы себе @@ -17,23 +5,6 @@ set_global_options = function( SYMBOL_DELIM = "; ", ... ) { - - 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()) @@ -81,16 +73,17 @@ check_and_init_scheme = function() { if (!all(file.exists(scheme_file))) { cli::cli_abort(c("Отсутствуют файлы схем для следующих наименований:", paste("-", names(scheme_file)[!file.exists(scheme_file)]))) } - + 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) diff --git a/app.R b/app.R index b7a5391..03a5117 100644 --- a/app.R +++ b/app.R @@ -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 ----------