diff --git a/R/init.R b/R/init.R index 96fb8ab..68bfbf8 100644 --- a/R/init.R +++ b/R/init.R @@ -33,7 +33,7 @@ init <- function( } -.preflight_checks <- function(new_package, skip_availability, .local) { +.preflight_checks <- function(new_package, skip_availability = FALSE, .local = FALSE) { cli::cat_rule("Running preflight checklist", col = "cyan", line = 2) cli::cli_progress_message(cli::col_grey("{cli::pb_spin} Checking that no folder named `{new_package}` already exists")) @@ -67,7 +67,7 @@ init <- function( return(creds) } -.check_creds <- function(new_package, .local) { +.check_creds <- function(new_package, .local = FALSE) { ## git if (!.local) { @@ -111,7 +111,7 @@ init <- function( return(creds) } -.creds_git <- function(.local) { +.creds_git <- function(.local = FALSE) { ## Check that git is configured cli::cli_progress_message(cli::col_grey("{cli::pb_spin} Checking git configuration")) @@ -151,6 +151,11 @@ init <- function( cli::cli_abort("Could not find any stored Github credentials. Consider adding a Github token (a.k.a. `PAT`) to your `.Renviron`.\n") } ) + gh_scopes <- gh::gh_whoami(.token = PAT)$scopes + for (scope in c("repo", "workflow", "user:email")) { + if (!grepl(scope, gh_scopes)) + cli::cli_abort("The provided PAT does not authorize the `{scope}` scope. Please change the PAT settings @ https://github.com/settings/tokens to enable this scope.\n") + } gh_user <- gh::gh_whoami(.token = PAT)$login cli::cli_alert_success(cli::col_grey("Successfully logged in Github")) cli::cli_ul(c( @@ -162,7 +167,7 @@ init <- function( ## Get all repos for one user req <- gh::gh("/users/{user}/repos", user = gh_user, per_page = 30, .token = PAT) gh_repos <- purrr::map_chr(req, 'name') - while({length(gh_repos) %% 30} == 0) { + while({length(gh_repos) %% 30} != 0) { req <- gh::gh_next(req) gh_repos <- c(gh_repos, purrr::map_chr(req, 'name')) } diff --git a/myBook80 b/myBook80 new file mode 160000 index 0000000..d7ed16c --- /dev/null +++ b/myBook80 @@ -0,0 +1 @@ +Subproject commit d7ed16ca12e83b773d5c3d1de8568d6c58a90ec3 diff --git a/myBook81 b/myBook81 new file mode 160000 index 0000000..4caa57a --- /dev/null +++ b/myBook81 @@ -0,0 +1 @@ +Subproject commit 4caa57aa201bb1e5962acbb68a6a94d7a7c48b1c