/mac-setup

Scripts and baseline dotfiles for setting up a new CFPB developer Mac

Primary LanguageShellCreative Commons Zero v1.0 UniversalCC0-1.0

CFPB Mac setup scripts

Configurations and scripts for setting up a new developer Mac.

Note: These scripts currently target macOS Big Sur (11). If you need to setup a Mojave (10.14) Mac, please use the tagged release for Mojave.

Automated software setup

The mac_setup.sh script installs a standard developer environment on new Mac computers, with the goal of making the machine ready to set up consumerfinance.gov for local development.

This includes, but is not limited to:

  • Homebrew
  • Up-to-date or cfgov-refresh-specific versions of several core developer tools:
    • Git (replacing Apple Git)
    • git-secrets hooks for ensuring you don't accidentally commit bad stuff
    • pyenv and pyenv-virtualenvwrapper with Python 3.8.12
    • pipx for running isolated Python applications
    • nvm with the latest LTS release of Node
    • Yarn with the following installed globally:
      • yo
      • generator-cf
      • generator-node
      • snyk
  • Minimal dotfiles with the necessary bits for all of the above to work as expected

Running the script

  1. Run the following command from the root of this repository to initiate the installation: ./mac_setup.sh.
  2. After the script completes, run source ~/.zshenv to apply the changes to your current terminal session, or just close the session and open a new one.

Scripts to set up each component can also be run individually:

  • preflight.sh to check network access and local configuration before proceeding
  • homebrew_setup.sh to install and configure Homebrew
  • python_setup.sh to install and configure our Python development environment
  • node_setup.sh to install and configure our Node development environment
  • git_setup.sh to install and configure git and git-secrets
  • dotfiles_setup.sh to apply our standard dotfiles

Backups

  • If any dotfiles (~/.bash_profile, ~/.bashrc, etc.) would be overwritten, they will be backed up to ~/<filename>_<date>.
  • If you have anything in your ~/.git-templates/ folder and your global .gitconfig has init.templateDir value is set to that location, your files will be left in place and the init.templateDir will be changed to ~/.git-templates/git-secrets/.

GitHub/SSH setup

The github_setup.sh script has two functions:

  1. Ensure the ~/.gitconfig file in your home directory has a name and email address configured so that you get credit for your commits.
  2. Create an SSH key (if it doesn't already exist) for integration with GitHub.com and CFPB's GitHub Enterprise instance.
    • If generating an SSH key, you will be prompted to create a password for the key.

After the script completes, you will be provided with a "public key" and the following instructions for applying the key to your two GitHub accounts:

  1. Log into your GitHub accounts and paste this public key in the GitHub Settings website
  2. Directions for adding keys

The script is safe to run even if you have already configured your .gitconfig and/or SSH key. In this case, the tool will simply output your existing details for your review.

Running the script

Run the following command from the root of this repository: ./github_setup.sh.