-
Notifications
You must be signed in to change notification settings - Fork 1
/
dev_history_r_proj.R
128 lines (90 loc) · 3.35 KB
/
dev_history_r_proj.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# update template ---------------------------------------------------------
library(fs)
file_copy("../dev_history/refs/dev_history_r_proj.R",
".",
overwrite = TRUE)
# setup -------------------------------------------------------------------
library(devtools)
use_git()
# CTRL + F1 show Git
library(devtools)
use_build_ignore("dev_history_r_proj.R")
library(magrittr)
# add desc ----------------------------------------------------------------
library(usethis)
add2pkg::create_desc()
author_info <- add2pkg::add_me(is_paste = TRUE)
desc_lines <- readr::read_lines("DESCRIPTION")
desc_lines[5] <- author_info
desc_lines %>% readr::write_lines("DESCRIPTION")
# file.edit("DESCRIPTION")
library(tidyverse)
# add license -------------------------------------------------------------
options(usethis.full_name = "Jiaxiang Li")
use_cc0_license()
# add namespace -----------------------------------------------------------
use_namespace()
# add makefile ------------------------------------------------------------
usethis::use_make()
# coding ------------------------------------------------------------------
# prettify ----------------------------------------------------------------
if (file.exists("README.Rmd")) {
file.rename("README.Rmd", "README-bak.Rmd")
file.edit("README-bak.Rmd")
}
use_readme_rmd(open = FALSE)
read_lines("README.Rmd")[1:22] %>%
c("") %>%
c('`r add2pkg::add_disclaimer("Jiaxiang Li")`') %>%
write_lines("README.Rmd")
file.remove("README-bak.Rmd")
# file.edit("README.Rmd")
rmarkdown::render("README.Rmd")
rstudioapi::viewer("README.html")
file.remove("README.html")
# add examlpes ------------------------------------------------------------
clipr::read_clip() %>%
str_c("#' ", .) %>%
clipr::write_clip()
clipr::read_clip() %>%
str_c("#' \\dontrun{", ., "}") %>%
clipr::write_clip()
# add dirs ----------------------------------------------------------------
library(tidyverse)
library(fs)
list("analysis", "output", "refs") %>% map(dir.create)
# add commit --------------------------------------------------------------
git2r::add(path = ".")
glue::glue("Add metadata
1. license
1. readme
1. namespace
1. desc
1. Makefile") %>%
git2r::commit(message = .)
git2r::remote_add(name = "origin",
url = glue::glue("https://github.com/JiaxiangBU/{add2pkg::proj_name()}.git"))
library(git2r)
git2r::push(name = 'origin', refspec = "refs/heads/master",
cred = git2r::cred_token()
)
# delete object -----------------------------------------------------------
rm("author_info")
rm("desc_lines")
# update template ---------------------------------------------------------
library(fs)
file_copy("dev_history_r_proj.R", "../dev_history/refs/dev_history_r_proj.R",
overwrite = TRUE)
repo <- git2r::repository("../dev_history/")
repo %>% git2r::status()
repo %>% git2r::add(path = ".")
repo %>% git2r::status()
repo %>% git2r::commit(message = "Update r proj dev history.")
repo %>% git2r::push(name = 'origin', refspec = "refs/heads/master", cred = git2r::cred_token())
rm("repo")
# update local ------------------------------------------------------------
git2r::status()
git2r::add(path = "dev_history_r_proj.R")
git2r::status()
git2r::commit(message = "Update r proj dev history.")
git2r::push(name = 'origin', refspec = "refs/heads/master", cred = git2r::cred_token())