local-cli
local-cli copied to clipboard
Start Site with site name instead of site ID
Hi,
Would it be possible to start/stop sites using site name instead of site id ? The site id - is not as useful as we have to list all site ids - get the one we're looking for and then start it.
i second this, i've forked this project to add this support, we need a new mutation setting for start-server that allows name as the mutation var
Until they add support for this, perhaps these bash alias you can put in your bashrc or zshrc file might help
You can run these commands if you are in your terminal in the folder of said project. Usually i just "Z" (https://github.com/agkozak/zsh-z) to quickly travel via terminal to the client folder, and then type "localstart" to start their local instance.
function get_local_site_id() {
# MAKE SURE YOU HAVE @getflywheel/local-cli installed globally via npm.
# Get the current folder's name using Perl
local clientfolder=$(pwd | perl -pe 's|.*/Local Sites/([^/]*)/.*|$1|')
# List the sites and store the output in a variable
local sites_list=$(local-cli list-sites)
# Search for the value of $clientfolder in the sites list using Perl and extract the corresponding ID
local site_id=$(echo "$sites_list" | perl -ne '/.*\s([a-zA-Z0-9_-]+).*\s'"$clientfolder"'\s.*/ && print $1')
# Echo the matching ID
echo $site_id
}
function localssh() {
# MAKE SURE YOU HAVE @getflywheel/local-cli installed globally via npm.
local site_id=$(get_local_site_id)
echo "siteid : $site_id"
sh ~/Library/Application\ Support/Local/ssh-entry/$site_id.sh
}
function localstart() {
local site_id=$(get_local_site_id)
echo "siteid : $site_id"
local-cli start-site $site_id
}
function localstop() {
local site_id=$(get_local_site_id)
echo "siteid : $site_id"
local-cli stop-site $site_id
}
function localrestart() {
local site_id=$(get_local_site_id)
echo "siteid : $site_id"
local-cli stop-site $site_id
local-cli start-site $site_id
}
localssh only works if you have clicked the "Siteshell" code atleast for that specific site. (Then a ssh script is created by local, and we just execute that script using our bash alias and naming scheme)