diff --git a/content/blog/here-1-0-0/index.Rmd b/content/blog/here-1-0-0/index.Rmd new file mode 100644 index 000000000..834a226fa --- /dev/null +++ b/content/blog/here-1-0-0/index.Rmd @@ -0,0 +1,109 @@ +--- +output: hugodown::hugo_document + +slug: here-1-0-0 +title: here 1.0.0 and rprojroot 2.0.2 +date: 2020-11-15 +author: Kirill Müller +description: > + here offers a simple way to find your files in a project-oriented workflow. + Under the hood, rprojroot implements the logic. + Version 1.0.0 introduces a new way to declare the project root, and brings a few other features. + +photo: + url: https://unsplash.com/photos/C2zhShTnl5I + author: Nick Fewings + +# one of: "deep-dive", "learn", "package", "programming", or "other" +categories: [package] +tags: [] +--- + + + +We're chuffed to announce the release of [here](https://here.r-lib.org/) 1.0.0 and [rprojroot](https://rprojroot.r-lib.org/) 2.0.2. +here offers a simple way to find your files in a [project-oriented workflow](https://rstats.wtf/project-oriented-workflow.html). +Under the hood, rprojroot implements the logic. +Version 1.0.0, the first update since the original CRAN release, introduces a new way to declare the project root. +This release also includes an overhaul of the documentation and added safety for path construction. + +You can install it from CRAN with: + +```{r, eval = FALSE} +install.packages("here") +``` + +This blog post shows the two most important user-facing changes: declaring the project root in your scripts and reports, and mixing project-relative and absolute paths. +You can see a full list of changes in the release notes for [here](https://here.r-lib.org/news/index.html) and [rprojroot](https://rprojroot.r-lib.org/news/index.html). + +## Here I am! + +The source of this blog post lives in the `index.Rmd` file in the `content/blog/here-1-0-0` subdirectory of the [tidyverse.org](https://github.com/tidyverse/tidyverse.org) repository. +It declares its own location: + +```{r} +here::i_am("content/blog/here-1-0-0/index.Rmd") +``` + +A message describes the location of the project root on my machine. +It is probably different on your machine, the purpose of the here package is to help with that situation. + +After establishing the project root, the `here()` function helps navigate the project. + +```{r} +library(here) +library(conflicted) + +dir(here("content", "blog", "here-1-0-0")) +dir(here("content/blog/here-1-0-0")) +strwrap(readLines(here("CODE_OF_CONDUCT.md"), 5)) +``` + +You can still load[^attach] the here package without calling `here::i_am()`. +The new approach resolves ambiguity and also protects against running the file in the wrong project or outside of a project: + +[^attach]: attach with `library()` + +```{r error = TRUE} +here::i_am("foo/bar.R") +``` + +Read more at `vignette("here", package = "here")`. + + +## Absolute vs. relative paths + +The result of `here()` is always a character vector with absolute paths. +Prior to rprojroot 2.0.2, passing absolute paths to `here()` resulted in garbage. +The update modifies this behavior: if the first argument to `here()` is an absolute path, the project root is ignored and `here()` works like `file.path()`: + +```{r} +blog_path <- here("content/blog/here-1-0-0") +blog_path +here("content/blog/here-1-0-0", "index.Rmd") +here(blog_path, "index.Rmd") +``` + +This allows mixing project-relative and absolute paths without compromising on safety. + + +## Acknowledgements + +We would like to thank the contributors who have helped with this release with pull requests and discussion. + +### here + +[@ABcreation98](https://github.com/ABcreation98), [@Alanocallaghan](https://github.com/Alanocallaghan), [@antass](https://github.com/antass), [@batpigandme](https://github.com/batpigandme), [@boshek](https://github.com/boshek), [@cderv](https://github.com/cderv), [@chris-prener](https://github.com/chris-prener), [@cloversleaves](https://github.com/cloversleaves), [@cportner](https://github.com/cportner), [@czeildi](https://github.com/czeildi), [@ghost](https://github.com/ghost), [@hadley](https://github.com/hadley), [@ijlyttle](https://github.com/ijlyttle), [@JamesCuster](https://github.com/JamesCuster), [@jasonpott](https://github.com/jasonpott), [@jennybc](https://github.com/jennybc), [@karldw](https://github.com/karldw), [@kpjonsson](https://github.com/kpjonsson), [@lgaborini](https://github.com/lgaborini), [@LTzavella](https://github.com/LTzavella), [@moodymudskipper](https://github.com/moodymudskipper), [@NoushinN](https://github.com/NoushinN), [@nzgwynn](https://github.com/nzgwynn), [@pjrdata](https://github.com/pjrdata), [@prosoitos](https://github.com/prosoitos), [@rajanand](https://github.com/rajanand), [@robertamezquita](https://github.com/robertamezquita), [@Sebaristoteles](https://github.com/Sebaristoteles), [@sharlagelfand](https://github.com/sharlagelfand), [@smach](https://github.com/smach), [@solarchemist](https://github.com/solarchemist), [@StevenHibble](https://github.com/StevenHibble), [@StevenMMortimer](https://github.com/StevenMMortimer), [@swayson](https://github.com/swayson), and [@yogat3ch](https://github.com/yogat3ch). + +### rprojroot + +[@BarkleyBG](https://github.com/BarkleyBG), [@batpigandme](https://github.com/batpigandme), [@ctbrown](https://github.com/ctbrown), [@florisvdh](https://github.com/florisvdh), [@hadley](https://github.com/hadley), [@hansvancalster](https://github.com/hansvancalster), [@jennybc](https://github.com/jennybc), [@jonathan-g](https://github.com/jonathan-g), [@jthurner](https://github.com/jthurner), [@kslays](https://github.com/kslays), [@moodymudskipper](https://github.com/moodymudskipper), [@uribo](https://github.com/uribo), and [@yonicd](https://github.com/yonicd). diff --git a/content/blog/here-1-0-0/index.md b/content/blog/here-1-0-0/index.md new file mode 100644 index 000000000..e90ae5670 --- /dev/null +++ b/content/blog/here-1-0-0/index.md @@ -0,0 +1,150 @@ +--- +output: hugodown::hugo_document + +slug: here-1-0-0 +title: here 1.0.0 and rprojroot 2.0.2 +date: 2020-11-15 +author: Kirill Müller +description: > + here offers a simple way to find your files in a project-oriented workflow. + Under the hood, rprojroot implements the logic. + Version 1.0.0 introduces a new way to declare the project root, and brings a few other features. + +photo: + url: https://unsplash.com/photos/C2zhShTnl5I + author: Nick Fewings + +# one of: "deep-dive", "learn", "package", "programming", or "other" +categories: [package] +tags: [] +rmd_hash: 941faf1943715603 + +--- + + + +We're chuffed to announce the release of [here](https://here.r-lib.org/) 1.0.0 and [rprojroot](https://rprojroot.r-lib.org/) 2.0.2. here offers a simple way to find your files in a [project-oriented workflow](https://rstats.wtf/project-oriented-workflow.html). Under the hood, rprojroot implements the logic. Version 1.0.0, the first update since the original CRAN release, introduces a new way to declare the project root. This release also includes an overhaul of the documentation and added safety for path construction. + +You can install it from CRAN with: + +
install.packages("here")
+
+
+here::i_am("content/blog/here-1-0-0/index.Rmd")
+
+#> here() starts at /home/kirill/git/R/tidyverse.org
+
+
+library(here)
+library(conflicted)
+
+dir(here("content", "blog", "here-1-0-0"))
+
+#> [1] "index.md" "index.Rmd" "thumbnail-sq.jpg" "thumbnail-wd.jpg"
+
+dir(here("content/blog/here-1-0-0"))
+
+#> [1] "index.md" "index.Rmd" "thumbnail-sq.jpg" "thumbnail-wd.jpg"
+
+strwrap(readLines(here("CODE_OF_CONDUCT.md"), 5))
+
+#> [1] "# Contributor Covenant Code of Conduct"
+#> [2] ""
+#> [3] "## Our Pledge"
+#> [4] ""
+#> [5] "In the interest of fostering an open and welcoming environment, we as"
+#> [6] "contributors and maintainers pledge to making participation in our"
+#> [7] "project and our community a harassment-free experience for everyone,"
+#> [8] "regardless of age, body size, disability, ethnicity, gender identity"
+#> [9] "and expression, level of experience, nationality, personal appearance,"
+#> [10] "race, religion, or sexual identity and orientation."
+
+
+here::i_am("foo/bar.R")
+
+#> Error: Could not find associated project in working directory or any parent directory.
+#> - Path in project: foo/bar.R
+#> - Current working directory: /home/kirill/git/R/tidyverse.org/content/blog/here-1-0-0
+#> Please open the project associated with this file and try again.
+
+
+blog_path <- here("content/blog/here-1-0-0")
+blog_path
+
+#> [1] "/home/kirill/git/R/tidyverse.org/content/blog/here-1-0-0"
+
+here("content/blog/here-1-0-0", "index.Rmd")
+
+#> [1] "/home/kirill/git/R/tidyverse.org/content/blog/here-1-0-0/index.Rmd"
+
+here(blog_path, "index.Rmd")
+
+#> [1] "/home/kirill/git/R/tidyverse.org/content/blog/here-1-0-0/index.Rmd"
+
+
+