Skip to content
/ dr Public

Task wrapper and shortener for common Drupal Drush Composer commands.

License

Notifications You must be signed in to change notification settings

diqidoq/dr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dr

Command line wrapper for Drush / Composer managed Drupal projects

<dr> is a simple sh based lazy typer command line tool which wraps frequently tasks with commands of Drush and Composer to unify and abbreviate (shorten) the daily Drupal experience of installing, updating and removing extensions, setting up new projects, creating backups, repair permissions and more. It is NOT another console! It fully embraces Drush and Composer and you should learn to use them before using a shortener like , which is helpful when you know what you are doing and you are often in a rush to service Drupal via command line.

We make spaghetti commands like

composer require drupal/modul1 drupal/module2 drupal/module3
drush en module1 module2 module3 && drush cr

to simply dri module1 module2 module3. Text file lists are supported like dri modules.txt, dri modules.log (or later supported @todo dri modules.csv).

But these are split tasks and each step will be confirmed. so dri module can also be used to simply enable or disable a module. For example: The -r flag inverts the -i command and goes through the process of disabling and removing in 2 confirmed steps. The -tp flag lists all variants (bundle types) of your given entity type. And these commands have short link wrappers. So dr -r can be called simply with drr, and dr -bkp can be called with drbkp and so on.

NOTE: At the moment the script primary supports Drupal project roots build like drupal/web/core with drupal/web/sites/default/files like provided by the Drupal Composer project-recommended repository. But most simple tasks should work ether way. More variants of project trees are planned. This script has been initially developed for internal use in our offices only and we want to make it available public as a contribution to the wonderful Drupal community. So some tasks are still remaining for a full cross compatible public version yet.

Limitations and future plans

At the moment the install and removal part of the script is for Drupal extensions only (no other vendor packages yet) and is targeted mainly to bash shell, but with sh* cross compatible commands and future plans. Cross compatibility to other shells and other parts of a Drupal project packages like Drupal Composer dependencies are planned. Feel free to contribute to it here on github.

How to install

Simply clone the Github repository (or download it) which can be found under https://github.com/diqidoq/dr and move or symlink the executable files inside bin/ to your command line tools folder. Common is the username/bin or /usr/local/bin folder. Or create one if you don't have one. Make sure this bin folder is added to your PATH and the command executables are set as executables with chmod u+x. If you are new to this read about executable scripts and how to access them on your machine. Search engines are full of tutorials on this. Using sym links has the advantage of using updated versions automatically on each git pull or new clone.

Example installation

If your executables folder is under your-user-name/bin and your default shell is bash, then the install commands can look like this:

cd userfolder
git clone [email protected]:diqidoq/dr.git
ln -s ~/dr/bin/* ~/bin/
chmod u+x ~/bin/*
source ~/.bashrc

You can test it in a Drupal root with drerr or drwarn for example to get Drupal system errors or warnings from reports of level 1 and 2 very quick. Or with dri coffee to simply require and install (enable) the latest version of the gorgeous coffee module compatible with your Drupal version.

Requirements

Composer and Drush accessible in your Drupal ^8|^9|^10 root. NOTE: For Drupal before 10 you need Drush Launcher that dr detects Drush correctly. For Drupal 10 and higher other workarounds are recommended. Read more about the reasons and solutions at this Drush Launcher issue or follow this little bash config trick by awesome Drupal community member and long-term contributor @chx.

How to use

Install, checkout, update or remove multiple Drupal extensions in one simple line. Simply type one of the following:

  • dr extension-machine-name
  • dr extension-machine-name1 extension-machine-name2
  • dr extension-machine-name1, extension-nachine-name2

to get a Drupal module or other extension via Composer, and it will do the rest for you with help of Composer, some SHELL, PHP and some checks and finally with Drush if wanted. Same commands with a leading -r flag will invert the behaviour of dr and uninstall via Drush and remove multiple extensions via Composer. Or you can use the short link drr instead of dr -r. Same goes for dr -c (checkout/info) using drc or dr -s (show outdated) using drs. And so on. @todo Tutorials and code examples will follow one day.

The list of all short link commands regarding dr can be found in https://github.com/diqidoq/dr/tree/main/bin. Some need arguments like extension1 extension2 but some are global short commands like drprm for permission repair.

Feel free to use but consider support

I think the best of Open Source is sharing knowledge so please consider helping here to make it a better tool with issue reports and patches/merges when you use this tool. So we all win and you will get an improved tool on each release.

About

Task wrapper and shortener for common Drupal Drush Composer commands.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages