drupal-composer / drupal-project

:rocket: Composer template for Drupal projects. Quick installation via "composer create-project drupal-composer/drupal-project"
GNU General Public License v2.0
1.57k stars 941 forks source link

Bash script to select Drupal version before create-project #684

Closed emilorol closed 1 month ago

emilorol commented 1 month ago

I would have love for this to be part of a regular composer script, but I keep finding myself digging for the version to install. This is the following script I use to pick the version.

Note: This is script is very basic and I am sure it can be made better and with a more robust interactivity support:

#!/bin/bash

echo "Which Drupal version would you like to install?"
echo "1) Drupal 8"
echo "2) Drupal 9"
echo "3) Drupal 10"
echo "4) Drupal 11"

read -p "Choose an option (1 to 4): " version

if [ "$version" == "1" ]; then
    composer create-project drupal-composer/drupal-project:8.x-dev some-dir-v8 --no-interaction
elif [ "$version" == "2" ]; then
    composer create-project drupal-composer/drupal-project:9.x-dev some-dir-v9 --no-interaction
elif [ "$version" == "3" ]; then
    composer create-project drupal-composer/drupal-project:10.x-dev some-dir-v10 --no-interaction
elif [ "$version" == "4" ]; then
    composer create-project drupal-composer/drupal-project:11.x-dev some-dir-v11 --no-interaction
else
    echo "Invalid option. Please choose between 1 to 4."
fi

To use it:

  1. save its content in a file name for example install.sh
  2. add execution permission to it like chmod +x install.sh
  3. run it by calling ./install.sh

Output should be like:

~/testing$ ./install.sh 
Which Drupal version would you like to install?
1) Drupal 8
2) Drupal 9
3) Drupal 10
4) Drupal 11
Choose an option (1 to 4): 
leymannx commented 1 month ago

I think this is a nice and helpful script for some use-cases. Usually you would only need the latest version, though.

It's just here is the place for issues with the Composer project itself. Thus, closing this issue and sending you to discuss it maybe at https://drupal.slack.com or somewhere else more open for different topics.

leymannx commented 1 month ago

Maybe publish it at https://gist.github.com/. There you can version-track it and people can add comments and stars. ⭐

emilorol commented 1 month ago

Thank you. I have done just that. I also improved the script a bit.

For those interested you can see the new version here: