Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate list of hosted development sites after vagrant up #1521

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/trellis/vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ def post_up_message
msg << "\n* You can SSH into the machine with `vagrant ssh`."
msg << "\n* Then navigate to your WordPress sites at `/srv/www`"
msg << "\n or to your Trellis files at `#{ANSIBLE_PATH_ON_VM}`."
sites = YAML.load_file(File.join(ANSIBLE_PATH, 'group_vars/development/wordpress_sites.yml'))
wordpress_sites = sites['wordpress_sites']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already available as trellis_config.wordpress_sites

Copy link
Member Author

@MWDelaney MWDelaney Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trellis_config wasn't available so I loaded it the same way the Vagrantfile does.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you actually get an error? This method is only used in the Vagrantfile which has trellis_config in scope.

If for some reason it doesn't work, you should change the post_up_message method to accept an trellis_config argument so it can be passed in.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did! Corrected per your suggestion.

if wordpress_sites.any?
msg << "\n\n\e[35m🚀 Development URLs: \e[0m"
wordpress_sites.each do |site_name, site|
MWDelaney marked this conversation as resolved.
Show resolved Hide resolved
site_url = site['site_hosts'].first
site_url = site_url.is_a?(Hash) ? site_url['canonical'] : site_url
site_url = site['ssl']['enabled'] ? "https://#{site_url}" : "http://#{site_url}"
MWDelaney marked this conversation as resolved.
Show resolved Hide resolved
msg << "\n
🌱 \e[37mName:\e[33m #{site_name}\e[0m
├── 🔗 \e[37mURL:\e[33m #{site_url}\e[0m
├── 🛠️ \e[37mAdmin:\e[33m #{site_url}/wp-admin\e[0m
└── 📩 \e[37mMailpit:\e[33m #{site_url}:8025\e[0m
"
end
end

msg
end
Expand Down
Loading