Why is Trellis not a Composer package?

Apologies if this is an odd question. Two (Bedrock and Sage) of the three Roots projects are installed with Composer, whereas the other (Trellis) is installed with Git. Why is Trellis not also installable via Composer or something similar?

The reason I ask is that, on at least two separate occasions, the master branch of Trellis has had a show-stopping bug or two that caused me hours of troubleshooting eventually solvable by simply checking out the latest tagged version. A Composer-installable Trellis would solve that issue, would it not? Or is there a Git command that will always clone the latest tagged version of a repo, and if there is, why is that not the command listed in the Trellis installation documentation?

Composer is for PHP so Trellis would fall into the “something similar” category. I suppose there’s two good candidates: pip or an Ansible galaxy role (Trellis is mostly Ansible’s YML + some python).

You’re correct that it’s not great for us to recommend just checking out master by default. master is of course more unstable than the releases. There’s just no easy way to get the “latest” tag from Git. It can be downloaded from GitHub however.

That’s exactly what https://github.com/roots/trellis-cli does. It fetches the latest releases and uses that instead of master. The docs will be updated at some point soon to use/assume trellis-cli as the default workflow.

I’ve been thinking about this a bit more lately. There’s just no perfect solution yet.

1 Like

Ah, I suspected it might be something to do with Trellis not being PHP. Thanks, I’ll check out Trellis CLI!

In the mean time, I cobbled this script together to setup a Roots project with the latest Trellis tagged version, Bedrock, and Sage, with some appropriate user prompts for folder names.

DISCLAIMER: I don’t know much about shell scripting, so use the following at your own risk. I do know it should be harmless in all cases, I just can’t guarantee it will work in all cases. I’ve tried writing scripts before that ended up working in zsh but not bash, or vice versa. I’m on macOS with iTerm and zsh, for what it’s worth.


NC='\033[0m' # No Color

# Prompt user for desired directory name
echo ${GREEN}Enter name of project folder to be created:${NC}
read -p "${PWD}/" project
mkdir "$project" && cd "$project"

# Clone Trellis, checkout latest tag, remove Git history
git clone git@github.com:roots/trellis.git && cd trellis
tag=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $tag -b latest-release && rm -rf .git
cd ..

# Install Bedrock
composer create-project roots/bedrock site
echo ${GREEN}Trellis and Bedrock installation complete.${NC}

# Give user option to quit now without installing Sage
read -p $'\e[0;32mContinue and install Sage?\e[0m [\e[1;33mY,n\e[0m]? \e[0m' -r
echo    # (optional) move to a new line
if [[ ${REPLY} =~ ^[Yy]$ ]] || [[ -z ${REPLY} ]]
  # Change to themes directory and prompt user for theme directory name
  cd site/web/app/themes
  echo ${GREEN}Enter name of theme folder to be created:${NC}
  read -p "site/web/app/themes/" theme
  # Install Sage
  composer create-project roots/sage ${theme}
  cd ${theme}
  yarn && yarn build

The specific lines relevant to this discussion being (this just feels dirty which is why I was asking if there might be a more elegant command or solution):

git clone git@github.com:roots/trellis.git && cd trellis
tag=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $tag -b latest-release && rm -rf .git
cd ..

This topic was automatically closed after 42 days. New replies are no longer allowed.