-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdev-setup.R
More file actions
154 lines (132 loc) · 5.41 KB
/
dev-setup.R
File metadata and controls
154 lines (132 loc) · 5.41 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# =============================================================================
# Development Environment Setup for selection.index Package
# =============================================================================
#
# This script installs all packages required for developing, testing, and
# building the selection.index package. Run this script when:
# - Setting up a new development environment
# - After cloning the repository
# - When you've forgotten which packages you need
#
# Usage:
# source("dev-setup.R")
#
# =============================================================================
cat("=============================================================================\n")
cat("Installing Development Dependencies for selection.index Package\n")
cat("=============================================================================\n\n")
# -----------------------------------------------------------------------------
# 1. Package Development Tools
# -----------------------------------------------------------------------------
cat("1. Installing Package Development Tools...\n")
dev_tools <- c(
"devtools", # Package development workflow
"usethis", # Automation for package development tasks
"roxygen2", # Documentation generation from inline comments
"pkgdown", # Build package website
"rcmdcheck" # Run R CMD check from R
)
for (pkg in dev_tools) {
if (!requireNamespace(pkg, quietly = TRUE)) {
cat(" Installing:", pkg, "\n")
install.packages(pkg, dependencies = TRUE)
} else {
cat(" Already installed:", pkg, "\n")
}
}
# -----------------------------------------------------------------------------
# 2. Testing Framework
# -----------------------------------------------------------------------------
cat("\n2. Installing Testing Framework...\n")
testing_pkgs <- c(
"testthat", # Unit testing framework
"covr" # Code coverage calculation
)
for (pkg in testing_pkgs) {
if (!requireNamespace(pkg, quietly = TRUE)) {
cat(" Installing:", pkg, "\n")
install.packages(pkg, dependencies = TRUE)
} else {
cat(" Already installed:", pkg, "\n")
}
}
# -----------------------------------------------------------------------------
# 3. Documentation & Vignettes
# -----------------------------------------------------------------------------
cat("\n3. Installing Documentation Tools...\n")
doc_pkgs <- c(
"knitr", # Dynamic report generation
"rmarkdown", # R Markdown document conversion
"markdown" # Markdown rendering for R
)
for (pkg in doc_pkgs) {
if (!requireNamespace(pkg, quietly = TRUE)) {
cat(" Installing:", pkg, "\n")
install.packages(pkg, dependencies = TRUE)
} else {
cat(" Already installed:", pkg, "\n")
}
}
# -----------------------------------------------------------------------------
# 4. Runtime Dependencies (from DESCRIPTION)
# -----------------------------------------------------------------------------
cat("\n4. Verifying Runtime Dependencies...\n")
runtime_pkgs <- c(
"stats", # Statistical functions (qt, pf)
"utils" # Utility functions (combn)
)
for (pkg in runtime_pkgs) {
if (!requireNamespace(pkg, quietly = TRUE)) {
cat(" Installing:", pkg, "\n")
install.packages(pkg, dependencies = TRUE)
} else {
cat(" Already installed:", pkg, "\n")
}
}
# -----------------------------------------------------------------------------
# 5. Optional: Code Quality Tools
# -----------------------------------------------------------------------------
cat("\n5. Installing Code Quality Tools (Optional)...\n")
quality_pkgs <- c(
"lintr", # Static code analysis
"styler", # Code formatting
"goodpractice" # Best practices checker for R packages
)
for (pkg in quality_pkgs) {
if (!requireNamespace(pkg, quietly = TRUE)) {
cat(" Installing:", pkg, "\n")
install.packages(pkg, dependencies = TRUE)
} else {
cat(" Already installed:", pkg, "\n")
}
}
# -----------------------------------------------------------------------------
# 6. Install Package Dependencies from DESCRIPTION
# -----------------------------------------------------------------------------
cat("\n6. Installing Package Dependencies from DESCRIPTION...\n")
if (requireNamespace("remotes", quietly = TRUE)) {
remotes::install_deps(dependencies = TRUE)
} else {
cat(" Installing remotes first...\n")
install.packages("remotes")
remotes::install_deps(dependencies = TRUE)
}
# -----------------------------------------------------------------------------
# Summary
# -----------------------------------------------------------------------------
cat("\n=============================================================================\n")
cat("Development Environment Setup Complete!\n")
cat("=============================================================================\n\n")
cat("Next steps:\n")
cat(" 1. Load the development package: devtools::load_all()\n")
cat(" 2. Run tests: devtools::test()\n")
cat(" 3. Check package: devtools::check()\n")
cat(" 4. Build documentation: devtools::document()\n")
cat(" 5. Build website: pkgdown::build_site()\n\n")
cat("Useful commands:\n")
cat(" - Install package locally: devtools::install()\n")
cat(" - Run specific test file: testthat::test_file('tests/testthat/test-*.R')\n")
cat(" - Check code coverage: covr::package_coverage()\n")
cat(" - Run code linting: lintr::lint_package()\n")
cat(" - Check best practices: goodpractice::gp()\n\n")
cat("=============================================================================\n")