BrewMyMac
BrewMyMac copied to clipboard
The coolest way to install apps and customize your Mac!
BrewMyMac
Possibly the coolest way to install apps and customize your Mac!
Introduction
This article explains the motivation behind this project.
Getting started
Try it: https://brewmymac.sh
Supported package repositories
- Homebrew: The missing package manager for macOS
- Homebrew Cask: An extension to Homebrew that allows you to install macOS applications
- App Store: A macOS app store platform maintained by Apple Inc
Supported macOS tweaks
- macOS tweaks: A collection of over 50 macOS customizations
Frontend
The frontend is a React single-page application created using Create React App. The code is located under frontend
directory.
Running locally
You need Node.js and npm installed on your machine.
- Install dependencies
npm i --legacy-peer-deps
- Change the homepage URL in
package.json
to.
- This app uses Sentry to track errors and Mixpanel to track usage. You can create a
.env
file and adding your own keys by setting theREACT_APP_MIXPANEL_TOKEN
andREACT_APP_SENTRY_DSN
environment variables. - Start the development server
npm start
- Open http://localhost:3000 with your browser
Building from source
You need Node.js and npm installed on your machine.
- Install dependencies
npm i --legacy-peer-deps
- Build the app
npm run build
- The built app will be in the
build
folder
Backend
The backend is a Node.js application targeted to run as Azure Functions. The code is located under backend
directory.
Deploying your own instance
Terraform is used to deploy the backend to Azure. The code is located under terraform
directory.
- Install Terraform
- Install Azure CLI
- Build the backend
cd backend npm run build cd ../terraform
- Authenticate with Azure: There are different ways to authenticate with Azure. See here for more details. Make sure the role running Terraform has the
Contributor
role on the subscription. - Run
terraform init
to initialize the Terraform working directory. You will probably need to change thebackend
configuration inbackends.tf
to use a different way to manage your Terraform state. - Run
terraform plan
to see what changes will be made to your infrastructure. You will probably need to change thevariables.tf
file to use a different resource group name, location, etc. - Run
terraform apply
to apply the changes. You will probably need to change thevariables.tf
file as explained above. - The backend will be deployed to Azure. You can now run the frontend locally or deploy it to Azure or GitHub Pages as well.
- You can run
terraform destroy
to destroy the backend when you no longer need it.
Architecture
- The frontend is a React app hosted on GitHub Pages. This project does not involve any backend service implementation.
- The frontend app fetches a list of available apps from Homebrew via its Formulae API.
- The frontend app fetches a list of available apps from Homebrew Cask via its Formulae API.
- The frontend app searches for apps in Apple App Store via a public CORS proxy.
- The frontend app fetches a list of available macOS tweaks from a GitHub repository.
- When the user is ready to install apps and apply tweaks, the frontend app generates a shell script, upload it via a backend API (Azure Functions) and stores it in Cosmos DB. A link to download the shell script is generated and a single-line command is displayed to the user.
- The user opens Terminal in macOS.
- The user runs the single-line command that downloads the shell script via a backend API (Azure Functions).
- The shell script downloads an Ansible playbook for macOS tweaks from GitHub.
- The shell script installs apps using Homebrew and mas-cli, and applies macOS tweaks using Ansible.
License
BrewMyMac is open source software released under MIT.