Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.
This repository was archived by the owner on May 1, 2025. It is now read-only.

Start Site with site name instead of site ID #12

Open

Description

@digamber89

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.

Activity

  1. Odinnh commented on Jan 19, 2024

    @Odinnh

    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

  2. WybeBosch commented on Dec 6, 2024

    @WybeBosch

    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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions