Skip to content

Commit

Permalink
3.0.0, before submission
Browse files Browse the repository at this point in the history
  • Loading branch information
notPlancha committed Jun 11, 2024
1 parent b78b919 commit 6573ebc
Show file tree
Hide file tree
Showing 14 changed files with 179 additions and 72 deletions.
12 changes: 10 additions & 2 deletions .Rprofile
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ if (interactive()) {
cli::cli_inform("ic_disable() to disable debug prints \n ic_enable() for the opposite")

}
build_docs <- \() {devtools::document()}
local_check <- \() {devtools::check()}
build_docs <- \() {devtools::document(roclets = c('rd', 'collate', 'namespace'))}
# n sei se este document esta certo mas e o que o rstudio chama
local_check <- \() {devtools::check(remote = T, cran = T)}
multi_check <- \() {
# melhor e por no github e ver, e ignorar isto
ch <<- rhub::rhub_check()
ch
}
print_cran_comments <- \(ch) {
# ja nao fuinciona, tirar no futuro
ch$cran_summary()
}
#revdep <- \() {revdepcheck::use_revdep()} # n percebi o q faz e n consegui correr
Expand All @@ -46,4 +49,9 @@ if (interactive()) {
goodpractice_check <- \() {
goodpractice::gp()
}

build_manual <- \() {
build_docs()
callr::rcmd("Rd2pdf", cmdargs = c( ".\\", "--no-clean"))
}
}
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 1.0.0
Date: 2024-01-28 17:48:51 UTC
SHA: 0734df96e43c51e39edc493122ee29d5d5f34716
Version: 2.0.0
Date: 2024-06-08 21:57:57 UTC
SHA: b78b919890d6e532f739fcb676c51baf4f6d5067
12 changes: 7 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Type: Package
Package: settingsSync
Title: Rstudio Addin to Sync Settings and Keymaps
Version: 2.0.0
Description: Rstudio Addin to sync settings, keymaps and keyboard
shortcuts, using Google Drive.
Title: 'Rstudio' Addin to Sync Settings and Keymaps
Version: 3.0.0
Description: Provides a 'Rstudio' addin to download, merge and upload 'Rstudio'
settings and keymaps, essencially 'syncing them' at will. It uses Google Drive
as a cloud storage to keep the settings and keymaps files.
License: Apache License (== 2)
URL: https://github.com/notPlancha/settingsSync
BugReports: https://github.com/notPlancha/settingsSync/issues
Expand All @@ -16,7 +17,8 @@ Imports:
googledrive,
jsonlite,
rappdirs,
tibble
tibble,
yesno
Encoding: UTF-8
NeedsCompilation: no
RoxygenNote: 7.3.1
Expand Down
13 changes: 0 additions & 13 deletions LICENSE

This file was deleted.

2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# settingsSync 2.0.0
# settingsSync 3.0.0

* Initial CRAN submission.
5 changes: 5 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Copyright (c) 2024 notPlancha
The project is licensed under the Apache License, Version 2.0.
You may obtain a copy of if at https://www.apache.org/licenses/LICENSE-2.0
The rest of this NOTICE is attribution and their respective licenses + conditions.
--------------------------------------------------------------------------------
Works under MIT License (MIT)
(copyright notices)
Expand All @@ -9,6 +13,7 @@ Works under MIT License (MIT)
- empty_json_file function Copyright (c) 2023 readr authors
- cli Copyright (c) 2023 cli authors
- glue Copyright (c) 2021 glue authors
- yesno Copyright (c) 2021 yesno authors
--------------------------------------------------------------------------------
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions R/mimic.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#' when running [utils::example()]. Internally, these change the options
#' "ss.mimic", "ss.mimic.local" and "ss.mimic.cloud".
#'
#' @returns nothing
#'
#' @name mimic-on-off
#' @examples
Expand Down
85 changes: 63 additions & 22 deletions R/sync.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,30 @@
#' Because of the way [googledrive::drive_put] is built, this function reads from
#' the files directly.
#'
#' @param do_all boolean, if TRUE will push all settings to gd, overwriting them.
#' This param overrides the values of the other params. Default is FALSE.
#' @param do_addins,do_editor_bindings,do_rstudio_bindings booleans, if TRUE will
#' push the respective file. Default is TRUE.
#' push the respective file. Default is FALSE
#' @param progBar function, designed to work with [progress_bar()]. Runs after
#' each file is pushed.
#'
#' @export
#'
#' @examples
#' mimic_on()
#' push() # will push all settings to gd, overwriting them
#' push(do_addins = FALSE) # will push only editor and rstudio bindings
#' push() # does nothing
#' push(do_all = TRUE) # will push all settings to gd, overwriting them
#' push(do_editor_bindings = FALSE, do_rstudio_bindings = FALSE)
#' # will push only editor and rstudio bindings
#' mimic_off()
#' @returns nothing
push <- function(do_addins= TRUE, do_editor_bindings= TRUE, do_rstudio_bindings= TRUE, progBar = NULL) {
push <- function(do_all = FALSE, do_addins= FALSE, do_editor_bindings= FALSE, do_rstudio_bindings= FALSE, progBar = NULL) {
if (do_all) {
do_addins <- TRUE
do_editor_bindings <- TRUE
do_rstudio_bindings <- TRUE
}

if(progBar |> is.null()) progBar <- \() {invisible()}
rstudio_path() -> path

Expand All @@ -42,36 +52,47 @@ push <- function(do_addins= TRUE, do_editor_bindings= TRUE, do_rstudio_bindings=
#'
#' Pulls Rstudio settings from Google Drive, without pushing. This is just a
#' helper function for [sync()], the main function, but can be used alone, although
#' this fucntion will not do any checking, and will just override.
#' this function will not do any checking, and will just override.
#'
#' @param all boolean, if TRUE will pull all settings from gd, overwriting them.
#' This param overrides the values of the other params. Default is FALSE.
#'
#' @param addins_gd,editor_bindings_gd,rstudio_bindings_gd character, the json
#' string to be written to the respective file; if NULL, will read from
#' Google Drive. Can also be FALSE to not write that specific file.
#' @param addins_gd,editor_bindings_gd,rstudio_bindings_gd character or boolean,
#' the json string to be written to the respective file or TRUE/FALSE;
#' if TRUE, will read from Google Drive;
#' if FALSE to not write that specific file. Default is FALSE
#'
#' @export
#'
#' @examples
#' mimic_on()
#' pull() # will pull all settings from gd, overwriting them
#' pull() # does nothing
#' pull(all = TRUE) # will pull all settings from gd, overwriting them
#' pull(addins_gd = '{"insertPipeOperator": "Shift+Tab"}',)
#' # will write to addins.json the string
#' pull(
#' addins_gd = '{"insertPipeOperator": "Shift+Tab"}',
#' editor_bindings_gd= FALSE, rstudio_bindings_gd= FALSE
#' addins_gd = '{"insertPipeOperator": "Shift+Tab"}',
#' editor_bindings_gd= TRUE
#' )
#' # will write to addins.json the string
#' pull(addins_gd = '{"insertPipeOperator": "Shift+Tab"}')
#' # will write to addins.json the stringand pull the other 2 files from gd
#' # will write to addins.json the string and pull editor_bindings from gd
#' mimic_off()
#' @seealso [read_from_gd()], [sync()], [push()]
#' @returns nothing
pull <- function(
addins_gd = NULL, editor_bindings_gd =NULL, rstudio_bindings_gd = NULL
all = FALSE,
addins_gd = FALSE, editor_bindings_gd =FALSE, rstudio_bindings_gd = FALSE
) {
if (all) {
addins_gd <- TRUE
editor_bindings_gd <- TRUE
rstudio_bindings_gd <- TRUE
}
rstudio_path() -> path

addins <- file.path(path, "keybindings", "addins.json")
editor_bindings <- file.path(path, "keybindings", "editor_bindings.json")
rstudio_bindings <- file.path(path, "keybindings", "rstudio_bindings.json")
if (is.null(addins_gd)){
if (isTRUE(addins_gd)){
# This unjsons it, and then jsons it again, no point in optimizing though
# at least it grants it's valid json
addins_gd <- read_from_gd("addins")
Expand All @@ -81,15 +102,15 @@ pull <- function(
addins_gd <- addins_gd |> jsonlite::unbox() |> jsonlite::toJSON(pretty= TRUE)
}
}
if (is.null(editor_bindings_gd)){
if (isTRUE(editor_bindings_gd)){
editor_bindings_gd <- read_from_gd("editor_bindings")
if(nrow(editor_bindings_gd) == 0) {
editor_bindings_gd <- "{}"
} else {
editor_bindings_gd <- editor_bindings_gd |> jsonlite::unbox() |> jsonlite::toJSON(pretty= TRUE)
}
}
if (is.null(rstudio_bindings_gd)){
if (isTRUE(rstudio_bindings_gd)){
rstudio_bindings_gd <- read_from_gd("rstudio_bindings")
if(nrow(rstudio_bindings_gd) == 0) {
rstudio_bindings_gd <- "{}"
Expand All @@ -108,23 +129,43 @@ pull <- function(
#' Gets the settings from Google Drive and from the local files, and merges them.
#' If there are conflicts, will ask the user to resolve them. Finally, will
#' write the merged settings to the local files, and push them to Google Drive.
#' Will first ask for confirmation if interactive. This function is what's called
#' by the addin.
#'
#' NOTE: if it's not interactive, it won't write to files because of CRAN policies.
#'
#' @param write boolean, if TRUE will write the merged settings to the local files,
#' and push them to Google Drive. FALSE essentially just makes conflict resolution,
#' without changing any files (basically a dry run). Default is TRUE.
#' without changing any files (basically a dry run). If a value orther than NULL
#' is provided, this will skip confirmation.
#' @param useProgBar boolean, if TRUE will show a progress bar. Default is TRUE.
#' @export
#'
#' @seealso [push()], [pull()]
#' @examples
#' mimic_on()
#' if(interactive()) {
#' sync(write= FALSE) # dry run, will not write to files or push to gd
#' sync() # will sync all settings, is what's run when called by addin
#' sync(write = TRUE) # will immediately try to sync all settings
#' sync(write = FALSE) # dry run, will not write to files or push to gd
#' sync() # will ask for confirmation, then sync all settings
#' }
#' mimic_off()
#' @returns nothing
sync <- function(write= TRUE, useProgBar = TRUE) {
sync <- function(write = NULL, useProgBar = TRUE) {
if (is.null(write)) {
if (interactive()) {
if (yesno::yesno("This will pull, try to merge and push your settings; continue?")) {
write <- TRUE
} else {
return(invisible())
}
} else {
write <- FALSE
}
}



progBar <- ifelse(useProgBar, progress_bar(6), NULL)
# pull, merge and push
addins_gd <- read_from_gd("addins", progBar = progBar)
Expand Down
8 changes: 6 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ rstudio_path <- function() {
if (is_mimic_on()) {
get_mimic_folder_local()
} else {
rappdirs::user_config_dir() |> file.path(ifelse(is_windows(), "Rstudio", "rstudio"))
rappdirs::user_config_dir() |>
file.path(ifelse(is_windows(), "Rstudio", "rstudio"))
}
}

Expand All @@ -41,7 +42,10 @@ read_file <- function(path) {
}

#'@noRd
write_file <- function(x, path) {
write_file <- function(x, path = NULL) {
if (path |> is.null()) {
path <- tempfile(fileext = ".txt")
}
dir.create(dirname(path), recursive = TRUE, showWarnings = FALSE)
cat(x, file = path)
}
3 changes: 3 additions & 0 deletions man/mimic-on-off.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 21 additions & 11 deletions man/pull.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions man/push.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6573ebc

Please sign in to comment.