Skip to content

Commit bfb7a1a

Browse files
committed
minimal install
1 parent 6a750a4 commit bfb7a1a

2 files changed

Lines changed: 122 additions & 0 deletions

File tree

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,35 @@ Creating an R package isn't just for CRAN submissions—it's about **building be
239239
- **Contributing**: Pull requests welcome! See `CONTRIBUTING.md` for guidelines
240240
- **Community**: Join the broader R package development community
241241

242+
## Minimal Installation
243+
244+
Impatient?
245+
Skip the setup grind and get straight to coding:
246+
247+
**Mac/Linux**
248+
249+
```sh
250+
curl -SL https://raw.githubusercontent.com/CenterForAssessment/packageSkeleton/main/minimal-install.R | Rscript -
251+
```
252+
253+
**Windows(PowerShell)**
254+
255+
```powershell
256+
(Invoke-WebRequest -Uri "https://raw.githubusercontent.com/CenterForAssessment/packageSkeleton/main/minimal-install.R").Content | Rscript -
257+
```
258+
259+
**What this does:**
260+
261+
- Asks you 4 questions (package name, author, etc.)
262+
- Generates clean R package structure
263+
- Creates working Hello World function with docs
264+
- Includes parameterized Quarto example
265+
- Initializes Git repo
266+
267+
No cloning. No find/replace battles. No wondering if you missed something.
268+
269+
*Prefer the traditional workflow? The full template approach continues below.*
270+
242271
---
243272

244273
**Ready to start building?** [Use this template](https://github.com/CenterForAssessment/packageSkeleton/generate) and create your first R package today! 🎉

minimal-install.R

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env Rscript
2+
3+
if (!requireNamespace("devtools", quietly = TRUE)) {
4+
stop("Please install devtools first: install.packages('devtools')")
5+
}
6+
7+
if (!requireNamespace("usethis", quietly = TRUE)) {
8+
stop("Please install usethis first: install.packages('usethis')")
9+
}
10+
11+
cat("Package name: ")
12+
pkg_name <- readLines("stdin", n = 1)
13+
14+
cat("Package title: ")
15+
pkg_title <- readLines("stdin", n = 1)
16+
17+
cat("Author name: ")
18+
author_name <- readLines("stdin", n = 1)
19+
20+
cat("Author email: ")
21+
author_email <- readLines("stdin", n = 1)
22+
23+
cat("Package description (a few sentences): ")
24+
pkg_description <- readLines("stdin", n = 1)
25+
26+
usethis::create_package(pkg_name, open = FALSE)
27+
28+
setwd(pkg_name)
29+
30+
desc_content <- paste0(
31+
"Package: ", pkg_name, "\n",
32+
"Title: ", pkg_title, "\n",
33+
"Version: 0.0.0.9000\n",
34+
"Authors@R: person('", author_name, "', email = '", author_email, "', role = c('aut', 'cre'))\n",
35+
"Description: ", pkg_description, "\n",
36+
"License: MIT + file LICENSE\n",
37+
"Encoding: UTF-8\n",
38+
"Roxygen: list(markdown = TRUE)\n"
39+
)
40+
writeLines(desc_content, "DESCRIPTION")
41+
42+
hello <- paste0(
43+
"#' Hello World Function\n",
44+
"#' @return A greeting\n",
45+
"#' @export\n",
46+
"hello <- function() {\n",
47+
" 'Hello, world!'\n",
48+
"}"
49+
)
50+
writeLines(hello, file.path("R", "hello.R"))
51+
52+
devtools::document()
53+
54+
usethis::use_mit_license()
55+
56+
devtools::check()
57+
58+
qmd_file <- file("example.qmd", open = "w")
59+
60+
user_os <- R.version$os
61+
62+
writeLines(c(
63+
"---",
64+
paste("title: \"", pkg_title, "\"", sep = ""),
65+
paste("author: \"", author_name, "\"", sep = ""),
66+
"params:",
67+
" name: \"World\"",
68+
paste0(" os: \"", user_os, "\""),
69+
"engine: knitr",
70+
"---",
71+
"",
72+
paste("# Hello from ", pkg_title),
73+
"",
74+
"Hello, \`r params$name\`!",
75+
"",
76+
"This example shows basic parameterization. Your operating system appears to be: **\`r params$os\`**.",
77+
"",
78+
paste("Package created by ", author_name, ".")
79+
),
80+
qmd_file
81+
)
82+
83+
close(qmd_file)
84+
85+
system("git init")
86+
system("git add .")
87+
system("git commit -m 'Initial package setup'")
88+
89+
cat("Package created successfully!\n")
90+
cat("To push to GitHub:\n")
91+
cat("1. Create a new repository on GitHub\n")
92+
cat("2. git remote add origin https://github.com/yourusername/", pkg_name, ".git\n")
93+
cat("3. git push -u origin main\n")

0 commit comments

Comments
 (0)