diff --git a/R/zzz.R b/R/zzz.R index 41711d9..98102af 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -12,6 +12,21 @@ assign( envir = ct_env ) + +check_old_cache_message <- function() { + cli::cli_inform( + c( + "In the last version of comtradr the cache location has been changed, because it was not CRAN compliant. You can:", #nolint + 'v' = 'Migrate the cache and clean old files with {.run ct_migrate_cache()}', + 'x' = 'Ignore this warning, a new cache is created automatically.', + 'i' = "Delete your old cache manually with:", + '*' = "{.run rappdirs::user_cache_dir('comtradr') |> list.files(full.names = T) |> file.remove()}", #nolint + ' ' = "and", + '*' = "{.run rappdirs::user_cache_dir('comtradr_bulk') |> list.files(full.names = T) |> file.remove()}"), #nolint + class = "packageStartupMessage" + ) +} + .onAttach <- function(libname, pkgname) { ## throw a warning, if a cache in the non-compliant directory is detected ## but only if there is actually any files in this directory @@ -24,17 +39,8 @@ assign( length(list.files( rappdirs::user_cache_dir('comtradr_bulk') )) > 0)) { - packageStartupMessage(cli::cli_bullets( - c( - "In the last version of comtradr the cache location has been changed, because it was not CRAN compliant. You can:", #nolint - '*' = 'Migrate the cache and clean old files with {.run ct_migrate_cache()}', - '*' = 'Ignore this warning, a new cache is created automatically.', - '*' = "Delete your old cache manually with:", - '*' = "{.run rappdirs::user_cache_dir('comtradr') |> list.files(full.names = T) |> file.remove()}", #nolint - ' ' = "and", - '*' = "{.run rappdirs::user_cache_dir('comtradr_bulk') |> list.files(full.names = T) |> file.remove()}") #nolint - )) - } + check_old_cache_message() + } }