if [[ $ZSH_EVAL_CONTEXT != *:file* ]]; then echo "Error: This script must be sourced, not executed directly" echo "Usage: source $0" exit 1 fi [[ -o errexit ]] && __orig_errexit=true || __orig_errexit=false [[ -o pipefail ]] && __orig_pipefail=true || __orig_pipefail=false set -eo pipefail # Require admin upfront, needed for homebrew installing command line tools sudo -v tmp_dir="$(mktemp -d)" cleanup() { rm -rf "$tmp_dir" [[ $__orig_errexit = false ]] && set +e || set -e [[ $__orig_pipefail = false ]] && set +o pipefail || set -o pipefail } trap cleanup EXIT pyenv_was_missing=false if ! command -v pyenv >/dev/null; then pyenv_was_missing=true fi nvm_was_missing=false if ! command -v nvm >/dev/null; then nvm_was_missing=true fi if ! command -v brew >/dev/null; then NONINTERACTIVE=1 /bin/bash -c \ "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" echo >> ~/.zprofile echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)" fi if ! arch -x86_64 /usr/bin/true 2>/dev/null; then echo "Installing Rosetta..." softwareupdate --install-rosetta --agree-to-license fi brewfile="$tmp_dir/Brewfile" cat >"$brewfile" <<'BREWFILE' # python dependencies brew "openssl" brew "readline" brew "sqlite3" brew "xz" brew "tcl-tk@8" brew "libb2" brew "zstd" brew "zlib" brew "pkgconfig" # python tools brew "pyenv" brew "pyenv-virtualenv" brew "pipx" # node tools brew "nvm" brew "duckdb" # cli tools brew "gh" brew "jq" # git lfs brew "git-lfs" # apps we use cask "docker-desktop" cask "visual-studio-code" cask "gcloud-cli" cask "dbeaver-community" cask "bruno" BREWFILE brew bundle --file "$brewfile" git lfs install open -a "Docker" echo "Please complete Docker Desktop setup in the window that opened, then press Enter to continue..." read if [ "$pyenv_was_missing" = true ]; then echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc echo 'eval "$(pyenv init - zsh)"' >> ~/.zshrc echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.zshrc pyenv install 3.11 pyenv global 3.11 fi if [ "$nvm_was_missing" = true ]; then echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.zshrc echo '[ -s "$HOMEBREW_PREFIX/opt/nvm/nvm.sh" ] && \. "$HOMEBREW_PREFIX/opt/nvm/nvm.sh"' >> ~/.zshrc echo '[ -s "$HOMEBREW_PREFIX/opt/nvm/etc/bash_completion.d/nvm" ] && \. "$HOMEBREW_PREFIX/opt/nvm/etc/bash_completion.d/nvm"' >> ~/.zshrc fi pipx ensurepath source ~/.zshrc while ! gh auth status &>/dev/null; do echo "GitHub CLI is not authenticated. Please log in." if ! gh auth login; then echo "Login failed. Press Enter to retry or Ctrl+C to cancel..." read fi done echo "GitHub CLI authenticated successfully." while [ -z "$(gcloud auth list --filter=status:ACTIVE --format="value(account)")" ]; do echo "gcloud is not authenticated. Please log in." if ! gcloud auth login; then echo "Login failed. Press Enter to retry or Ctrl+C to cancel..." read fi done echo "gcloud authenticated successfully." while ! gcloud auth application-default print-access-token &>/dev/null; do echo "gcloud application-default credentials not found. Please log in." if ! gcloud auth application-default login; then echo "Login failed. Press Enter to retry or Ctrl+C to cancel..." read fi done echo "gcloud application-default credentials configured successfully." gcloud auth configure-docker --quiet gcloud auth configure-docker us-west1-docker.pkg.dev --quiet gcloud config set project sumble-358418 gcloud auth application-default set-quota-project sumble-358418 if [ ! -d ~/code/sumble ]; then echo "Cloning sumble repository..." mkdir -p ~/code GIT_LFS_SKIP_SMUDGE=1 gh repo clone SumbleData/sumble ~/code/sumble fi if ! grep -q "# sumble cli" ~/.zshrc; then cd ~/code/sumble/cli bash sumble.sh install cd - source ~/.zshrc sumble setup-local source ~/.zshrc else echo "Sumble CLI already set up in ~/.zshrc" fi if ! nvm list | grep -q 'v[0-9]'; then nvm install $(jq -r '.engines.node' ~/code/sumble/web/package.json) fi if [ ! -f ~/code/sumble/api/.personal.env ]; then echo "BREAK_ORG_IMPORTS_CSV_IN_FAVOR_OF_SPEED=1" > ~/code/sumble/api/.personal.env fi cd ~/code/sumble/api sumble mkvenv cd - cd ~/code/sumble/web npm ci cd - cd ~/code/sumble/notebooks sumble mkvenv cd - docker compose -f ~/code/sumble/docker/web-app-infra/docker-compose.yml up -d; jq -r '.recommendations[]' ~/code/sumble/.vscode/extensions.json | xargs -n 1 code --install-extension code ~/code/sumble cleanup