Skip to content

Commit

Permalink
Merge pull request #2 from samuelbharti/dev
Browse files Browse the repository at this point in the history
Soft pull
  • Loading branch information
samuelbharti authored Oct 7, 2024
2 parents 0800dd7 + 209eeba commit 7182003
Show file tree
Hide file tree
Showing 16 changed files with 184 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ dev.R
test_install
inst/doc
docs
dev_untrack.R
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ Suggests:
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
Imports:
lifecycle
lifecycle,
rstudioapi
URL: http://www.samuelbharti.com/peacock/
61 changes: 61 additions & 0 deletions R/init_changelog_md.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#' A changelog markdown template to document project progress
#'
#' @param path Path where markdown file is created
#' @param confirm Confirm path; logical input.
#'
#' @return Return markdown file in specified or current working directory
#' @export
#'
#' @examples
#' init_changelog_md()
init_changelog_md <- function(path = getwd(), confirm = TRUE){


# Display a message before the prompt
cat("You current working directory will be:\n")
cat(path)

if(confirm){
user_input <- tolower(
readline(
prompt = "Do you wish to create a Change log MD here? (y/yes to confirm): "
)
)
}else{
user_input <- "y"
}


# Check if the user input is 'y' or 'yes'
if (user_input %in% c("y", "yes")) {
wd_path <- path

markdown_content <- "
# CHANGELOG
``` txt
YYYY-MM-DD John Doe
* Big Change 1
* Another Change 2
```
"
aa <- file.path(wd_path,"CHANGELOG.md")
file.create(aa, showWarnings = FALSE)

if(file.exists(aa)){
fileConn <- file(aa)

writeLines(
markdown_content,
fileConn
)
close(fileConn)

}

} else {
cat("Change log MD initialization canceled.\n")
}

}
15 changes: 10 additions & 5 deletions R/init_shiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@
#' #proj_shiny_init()
#'
#' @export
init_shiny <- function(path = getwd()){
init_shiny <- function(path = getwd(), confirm = TRUE){


# Display a message before the prompt
cat("You current working directory will be:\n")
cat(path)

user_input <- tolower(
readline(
prompt = "Do you wish to create a project template here? (y/yes to confirm): "
)
if(confirm){
user_input <- tolower(
readline(
prompt = "Do you wish to create a project template here? (y/yes to confirm): "
)
)
}else{
user_input <- "y"
}


# Check if the user input is 'y' or 'yes'
if (user_input %in% c("y", "yes")) {
Expand Down
15 changes: 10 additions & 5 deletions R/init_template.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@
#' @export
#'
#' @examples
init_template <- function(template_name, path) {
#' init_template("shiny",getwd())
init_template <- function(template_name, path = getwd(), confirm = TRUE) {

# Display a message before the prompt
cat("You current working directory will be:\n")
cat(path)

user_input <- tolower(
readline(
prompt = "Do you wish to create a project template here? (y/yes to confirm): "
if(confirm){
user_input <- tolower(
readline(
prompt = "Do you wish to create a project template here? (y/yes to confirm): "
)
)
)
}else{
user_input <- "y"
}

if (user_input %in% c("y", "yes")) {

Expand Down
2 changes: 1 addition & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
url: https://www.samuelbharti.com/peacock/
url: http://www.samuelbharti.com/peacock/
template:
bootstrap: 5

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CHANGELOG

``` txt
YYYY-MM-DD John Doe
* Big Change 1
* Another Change 2
```
3 changes: 3 additions & 0 deletions inst/markdown/templates/changelog_md_template/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: "CHANGELOG MD"
description: "A template to document project progress"
create_dir: false
22 changes: 22 additions & 0 deletions inst/rmarkdown/templates/changelog_template/skeleton/skeleton.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: "[Project Name] Changelog"
author: "Author Name"
date: "`r Sys.Date()`"
output: html_document
---

```{r}
print(paste0("Last updated: ",Sys.time()))
```

------------------------------------------------------------------------

# CHANGELOG
------------------------------------------------------------------------

YYYY-MM-DD John Doe

- Big Change 1
- Another Change 2
-

3 changes: 3 additions & 0 deletions inst/rmarkdown/templates/changelog_template/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: "CHANGELOG RMD"
description: "A template to document project progress"
create_dir: false
8 changes: 8 additions & 0 deletions inst/rstudio/addins.dcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Name: Peacock: Shiny Template
Description: Shiny project with pre-defined structure and files
Binding: init_shiny
Interactive: true
Params:
confirm: FALSE


6 changes: 6 additions & 0 deletions inst/rstudio/templates/project/init_shiny.dcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Binding: init_shiny
Title: Peacock: Shiny Template
Subtitle: Create a new Shiny app project
Caption: Shiny project with pre-defined structure and files
Params:
confirm: FALSE
22 changes: 22 additions & 0 deletions man/init_changelog_md.Rd

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

2 changes: 1 addition & 1 deletion man/init_shiny.Rd

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

5 changes: 4 additions & 1 deletion man/init_template.Rd

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

22 changes: 22 additions & 0 deletions man/peacock-package.Rd

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

0 comments on commit 7182003

Please sign in to comment.