roots / trellis-cli

A CLI to manage Trellis projects
https://roots.io/trellis/
MIT License
166 stars 25 forks source link

Feature Request: generate .vault_pass for existing sites #300

Closed mike-sheppard closed 2 years ago

mike-sheppard commented 2 years ago

Terms

Summary

./trellis/.vault_pass is required for the trellis dotenv task to run. It'd be great if the dotenv command either:

Motivation

trellis new creates the ./trellis/.vault_pass but it isn't a commited file, so when a new user clones the repo/project + runs trellis init the vault pass is not created, leading to the error below.

Additional Context

Current error message from trellis dotenv on a project without a .vault_pass file

trellis dotenv error
swalkinshaw commented 2 years ago

Sorry for the delay @mike-sheppard and thanks for the good issue!

@TangRufus had started looking into this in #302 and then I was starting to prioritize fixing this after another report. I went down a similar path as @TangRufus to try to validate that a Vault pass file existed.

However, a .vault_pass isn't actually required. It's only required if the files are already encrypted. In those cases, generating a new password file isn't correct since you'd need the original password that was used to encrypt them.

Example:

  1. developer A creates a project + pushes it git
  2. developer B clones repo, runs trellis dotenv
  3. 💣 fails because B is missing .vault_pass

The solution is for B to get the password from A and create that file locally.

So ultimately I think the best solution is to just output the proper error message which will point anyone in the right direction:

trellis dotenv
[✘] Error templating .env file
[WARNING]: Error getting vault password file (default): The vault password file
/Users/scottwalkinshaw/dev/trellis/.vault_pass was not found
ERROR! The vault password file /Users/scottwalkinshaw/dev/trellis/.vault_pass was not found

https://github.com/roots/trellis-cli/pull/319 will do this and also fixes the hidden error output in a few other commands.

mike-sheppard commented 2 years ago

Yup sounds good! + that error msg is perfect 👍🏻