diff --git a/Makefile b/Makefile
index 73c4ed4..cd1092a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,18 @@
-install:
- ./git_sync.sh
- $(MAKE) wipe-generated-profile-file
- $(MAKE) os-install
- $(MAKE) common-install
+define REBOOT_MESSAGE
@echo "*** YOU MUST REBOOT **IF** this was ***"
@echo "*** the first time you've setup ***"
@echo "*** khan-dotfiles (i.e. if you are ***"
@echo "*** onboarding) ***"
@echo "*** (Reboot is required for browser ***"
@echo "*** to pickup CA for khanacademy.dev) ***"
+endef
+
+install:
+ ./git_sync.sh
+ $(MAKE) wipe-generated-profile-file
+ $(MAKE) os-install
+ $(MAKE) common-install
+ $(REBOOT_MESSAGE)
@echo ""
@echo "To finish your setup, head back to the"
@echo "setup docs:"
@@ -27,3 +31,12 @@ os-install:
common-install:
./setup.sh
+
+frontend-only:
+ ./git_sync.sh
+ $(MAKE) wipe-generated-profile-file
+ if [ `uname -s` = Darwin ]; then \
+ ./mac-setup.sh --frontend-only; \
+ fi
+ ./setup.sh --frontend-only
+ $(REBOOT_MESSAGE)
diff --git a/mac-setup-elevated.sh b/mac-setup-elevated.sh
index 823a1ef..9e1f0d1 100755
--- a/mac-setup-elevated.sh
+++ b/mac-setup-elevated.sh
@@ -11,12 +11,14 @@ SCRIPT=$(basename $0)
usage() {
cat << EOF
usage: $SCRIPT [options]
- --root
Use specified directory as root (instead of HOME).
+ --root Use specified directory as root (instead of HOME).
+ --frontend-only Only install tools needed for frontend development.
EOF
}
# Install in $HOME by default, but can set an alternate destination via $1.
ROOT="${ROOT:-$HOME}"
+FRONTEND_ONLY=false
# Process command line arguments
while [[ "$1" != "" ]]; do
@@ -25,6 +27,9 @@ while [[ "$1" != "" ]]; do
shift
ROOT=$1
;;
+ --frontend-only)
+ FRONTEND_ONLY=true
+ ;;
-h | --help)
usage
exit 0
@@ -72,6 +77,8 @@ fi
# It used to be we needed to install xcode-tools, now homebrew does this for us
#"$DEVTOOLS_DIR"/khan-dotfiles/bin/install-mac-gcc.sh
-# We use java for our google cloud dataflow jobs that live in webapp
-# (as well as in khan-linter for linting those jobs)
-install_mac_java
+if [ "$FRONTEND_ONLY" != "true" ]; then
+ # We use java for our google cloud dataflow jobs that live in webapp
+ # (as well as in khan-linter for linting those jobs)
+ install_mac_java
+fi
diff --git a/mac-setup-normal.sh b/mac-setup-normal.sh
index 589f828..c09aafe 100755
--- a/mac-setup-normal.sh
+++ b/mac-setup-normal.sh
@@ -15,7 +15,26 @@ tty_bold=`tput bold`
tty_normal=`tput sgr0`
# The directory to which all repositories will be cloned.
-ROOT=${1-$HOME}
+ROOT="${HOME}"
+FRONTEND_ONLY=false
+
+# Process command line arguments
+while [[ "$1" != "" ]]; do
+ case $1 in
+ -r | --root)
+ shift
+ ROOT=$1
+ ;;
+ --frontend-only)
+ FRONTEND_ONLY=true
+ ;;
+ *)
+ echo "Unknown argument: $1"
+ exit 1
+ esac
+ shift
+done
+
REPOS_DIR="$ROOT/khan"
# Derived path location constants
@@ -328,11 +347,14 @@ uninstall_node_mac
# The actual installation of these tools is done in `setup_mise` in setup.sh.
install_mise_mac
-"$DEVTOOLS_DIR"/khan-dotfiles/bin/mac-setup-postgres.py
+if [ "$FRONTEND_ONLY" != "true" ]; then
+ "$DEVTOOLS_DIR"/khan-dotfiles/bin/mac-setup-postgres.py
+
+ install_redis
+ install_image_utils
+ install_helpful_tools
+fi
-install_redis
-install_image_utils
-install_helpful_tools
install_watchman
install_python_tools
install_fastly
diff --git a/mac-setup.sh b/mac-setup.sh
index b03c826..b80c589 100755
--- a/mac-setup.sh
+++ b/mac-setup.sh
@@ -8,14 +8,16 @@ SCRIPT=$(basename $0)
usage() {
cat << EOF
usage: $SCRIPT [options]
- --root Use specified directory as root (instead of HOME).
- --all Install all user apps.
- --none Install no user apps.
+ --root Use specified directory as root (instead of HOME).
+ --all Install all user apps.
+ --none Install no user apps.
+ --frontend-only Only install tools needed for frontend development.
EOF
}
# Install in $HOME by default, but can set an alternate destination via $1.
ROOT="${ROOT:-$HOME}"
+FRONTEND_ONLY_FLAG=""
# Process command line arguments
while [[ "$1" != "" ]]; do
@@ -30,6 +32,9 @@ while [[ "$1" != "" ]]; do
-n | --none)
APPS="-n"
;;
+ --frontend-only)
+ FRONTEND_ONLY_FLAG="--frontend-only"
+ ;;
-h | --help)
usage
exit 0
@@ -73,11 +78,8 @@ fi
read -p "Press enter to continue..."
-# TODO(ericbrown): Pass command line arguments below
-# Note that ensure parsing arguments (above) doesn't hide anything
-
# Run setup that requires sudo access
-"$DEVTOOLS_DIR"/khan-dotfiles/mac-setup-elevated.sh "$APPS"
+"$DEVTOOLS_DIR"/khan-dotfiles/mac-setup-elevated.sh $APPS $FRONTEND_ONLY_FLAG
# Run setup that does NOT require sudo access
-"$DEVTOOLS_DIR"/khan-dotfiles/mac-setup-normal.sh
+"$DEVTOOLS_DIR"/khan-dotfiles/mac-setup-normal.sh $FRONTEND_ONLY_FLAG
diff --git a/setup.sh b/setup.sh
index d222b06..b98e3fb 100755
--- a/setup.sh
+++ b/setup.sh
@@ -10,8 +10,27 @@
# Bail on any errors
set -e
-# Install in $HOME by default, but can set an alternate destination via $1.
-ROOT=${1-$HOME}
+# Install in $HOME by default, but can set an alternate destination via --root.
+ROOT="${HOME}"
+FRONTEND_ONLY=false
+
+# Process command line arguments
+while [[ "$1" != "" ]]; do
+ case $1 in
+ -r | --root)
+ shift
+ ROOT=$1
+ ;;
+ --frontend-only)
+ FRONTEND_ONLY=true
+ ;;
+ *)
+ echo "Unknown argument: $1"
+ exit 1
+ esac
+ shift
+done
+
mkdir -p "$ROOT"
# the directory all repositories will be cloned to
@@ -36,6 +55,10 @@ DIR=$(dirname "$0")
IS_MAC=$(which sw_vers || echo "")
IS_MAC_ARM=$(test "$(uname -m)" = "arm64" && echo arm64 || echo "")
+if [ "$FRONTEND_ONLY" = "true" ] && [ -z "$IS_MAC" ]; then
+ echo "WARNING: --frontend-only is intended for macOS only and may not work correctly on this system."
+fi
+
# On a clean install of Mac OS X, /opt/homebrew/bin is not in the PATH.
# Thus, stuff installed with the arm64 version of homebrew is not visible.
# (This was not the case on intel macs where /usr/local/bin is in the path
@@ -175,7 +198,11 @@ clone_webapp() {
# By this point, we must have git and ka-clone working, so a failure likely
# means the user doesn't have access to webapp (it's the only private repo
# we clone here) -- we give a more useful error than just "not found".
- kaclone_repo git@github.com:Khan/webapp "$REPOS_DIR/" -p --email="$gitmail" --pre-push-lint || add_fatal_error \
+ local depth_flag=""
+ if [ "$FRONTEND_ONLY" = "true" ]; then
+ depth_flag="--depth=1"
+ fi
+ kaclone_repo git@github.com:Khan/webapp "$REPOS_DIR/" -p --email="$gitmail" --pre-push-lint $depth_flag || add_fatal_error \
"Unable to clone Khan/webapp -- perhaps you don't have access? " \
"If you can't view https://github.com/Khan/webapp, ask #it in " \
"Slack to be added."
@@ -227,7 +254,9 @@ clone_repos() {
clone_kaclone
clone_devtools
clone_webapp
- clone_mobile
+ if [ "$FRONTEND_ONLY" != "true" ]; then
+ clone_mobile
+ fi
clone_frontend
kaclone_repair_self
}
@@ -332,8 +361,11 @@ install_and_setup_gcloud # pre-req: setup_python
install_deps # pre-reqs: clone_repos, install_and_setup_gcloud
install_our_lovely_cli_deps # pre-req: clone_repos, install_deps
install_hooks # pre-req: clone_repos
-download_db_dump # pre-req: install_deps
-create_pg_databases # pre-req: install_deps
+
+if [ "$FRONTEND_ONLY" != "true" ]; then
+ download_db_dump # pre-req: install_deps
+ create_pg_databases # pre-req: install_deps
+fi
echo
echo "---------------------------------------------------------------------"