GithubHelp home page GithubHelp logo

changer's Introduction

changer

R-CMD-check

Changing the name of an existing R package is annoying but common task in the early stages of package development (at least for me). Package changer tries to automate this task:

  1. Validity and availability of the new package name is checked by using available from available).

  2. All complete words matching the package name are replaced in all R scripts, C/C++/Fortran/Stan source codes, markdown files, and typical files in R packages, i.e. files with extension .R, .cpp, .c, .h, .f, .f90, .f95, .stan, .md, .Rmd, .Rnw, .html, .yaml, .yml, and .bib, as well as files DESCRIPTION, NAMESPACE inst/CITATION, .Rbuildignore, and gitignore.

  3. Change file names containing the package name. Only checks files with extensions listed above, as well as files [oldname].Rproj, [oldname]-package.R, [oldname]-defunct.R, and [oldname]-deprecated.R.

  4. If run_roxygen is TRUE (default), old Rd files are removed.

  5. All files with extensions .o, .so, and .dll in /src are removed to force a rebuild of the package.

  6. Name of the package directory is changed.

  7. If change_git is TRUE (default), the remote url of the git repository is changed to match the new name. Note that you still need to change the name of the repository in Github/Bitbucket etc manually. For example in Github: Go to the URL of your Github package, click Settings near the top-right, change the name under Repository name, and click Rename.

  8. If run_roxygen is TRUE, update documentation and rebuild package.

Inspired by back-and-forth naming of the package particlefield) and Nick Tierney's blog post.

Additional issues (read above as well)

  • If the package is already published in CRAN, then you should first consult folks at CRAN whether they will accept the name change.

  • It is strongly recommended to have a backup backup before proceeding.

  • Note that if the old package name is a common word, it will be replaced in the docs etc as well!

Installation

You can install the developed version of changer from Github with:

devtools::install_github("helske/changer")

Usage

There is just one function in the package:

changer("../mypackagewithlongandboringname", "Rbitary")

News

May 2022

  • Fixed a major bug, now actually replaces the package name in the .R files!
  • With additional argument replace_all you can now replace also partial matches instead of just the whole word matches.

February 2022

  • changer now tests that the supplied path actually contains an R package by checking the existence of the DESCRIPTION file.
  • yaml files are also checked, and warning is given regarding the rda files, thanks to Mahmoud Ahmed.

changer's People

Contributors

helske avatar mahshaaban avatar

Stargazers

Andrew Allen Bruce avatar  avatar Andree Valle Campos avatar Tomoya Sasaki avatar Sam Parmar avatar  avatar Tao Wu avatar  avatar Robin Lovelace avatar Santtu Tikka avatar  avatar Jakub Nowosad avatar Dragoș Moldovan-Grünfeld avatar Lluís Revilla avatar 我是洗衣机 avatar  avatar  avatar Eric Book avatar Kittipos Sirivongrungson avatar Joe Thorley avatar Matt Dray avatar Aditya Mangal avatar Adam H. Sparks avatar Shawn Charles avatar Nicholas Tierney avatar Leo Lee avatar Jimmy Briggs avatar John MacKintosh avatar AM avatar lhmet avatar Denis Roussel avatar Ishtiayk avatar Pedro Cavalcante Oliveira avatar Robert Link avatar Neal Fultz avatar Maëlle Salmon avatar Garrick Aden-Buie avatar Indrajeet Patil avatar Tyler Littlefield avatar  avatar boB Rudis avatar John Blischak avatar Kyle Harris avatar Adam Gruer avatar Michael Sumner avatar Nathan Eastwood avatar Nate Teetor avatar Victor Perrier avatar

Watchers

James Cloos avatar  avatar Ross Gayler avatar

changer's Issues

Fails if the path to the package contains a `(`

The path to my package contains a (. When I run changer I get the following error (anonymized):

sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `'mv' /Users/orgadish/Dropbox (Work)/R packages/my_package /Users/orgadish/Dropbox (Work)/R packages/my_new_package'

What I've done so far is to move it to a different folder, run changer and then move it back.

overwriting

Would like to be able to use without overwriting the existing source tree by first copying to a new source tree. Thus if package is called A and is in source tree A and if we want to change it to B then it would create a new directory B by copying A to B and then operate in B.

Also the original version A could either be a directory tree or a .tar.gz file in which case it would be de-tar'd into B.

Unrecognised build type

When trying to run R_CMD_Check following name change I got the following message in build pane.

Doesn't allow me to rebuild the package locally after that

Give a warning when a package contains `.rda` files

Hi @helske
Data saved in a package can cause problems when changing the package names. I am not sure if there is a way to deal with this in changer, other than reading the files after changing the name.
I ran into this problem recently and the error message was not very informative. It would be nice if changer produced an error when .rda files are detected.
What do you think?

Modify `yml` files

Hi @helske
Thanks for this handy package. I wonder if you plan on including yml/yaml in the files to be modified when changing the package names. These files are now very prevalent in R packages and it would be great if it could be included.

Unexpected urban dictionary prompt

After submitting the changer::changer() command the following prompt appears without any context. Would be useful to know why this is being asked this as part of a package rename function. Thanks.

Urban Dictionary can contain potentially offensive results,
  should they be included? [Y]es / [N]o:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.