summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/downloadExpoApp.sh30
-rwxr-xr-xbin/postInstall40
-rwxr-xr-xbin/setup112
3 files changed, 182 insertions, 0 deletions
diff --git a/bin/downloadExpoApp.sh b/bin/downloadExpoApp.sh
new file mode 100755
index 0000000..1a7904a
--- /dev/null
+++ b/bin/downloadExpoApp.sh
@@ -0,0 +1,30 @@
+#!/bin/bash -e
+
+set -euo pipefail
+
+# based on https://github.com/yaron1m/expo-detox-typescript-example/blob/master/scripts/dl_expo_bins
+APP_PATH=./bin/Exponent.app
+
+if [ ! -d $APP_PATH ]; then
+ echo "First time running Detox -- downloading Expo client app"
+
+ # Sanity check
+ if [ ! -f "package.json" ]; then
+ echo "Oops - run this command from your project's root folder" >>/dev/stderr
+ exit 1
+ fi
+
+ # Make the app dir (this'll also make sure we already have the bin directory)
+ mkdir $APP_PATH
+
+ # query expo.io to find most recent ipaUrl
+ IPA_URL=`curl --silent --show-error https://expo.io/--/api/v2/versions | python -c 'import sys, json; print json.load(sys.stdin)["iosUrl"]'`
+
+ # download tar.gz
+ TMP_PATH=./exponent.tar.gz
+ curl --silent --show-error --output $TMP_PATH $IPA_URL
+
+ # unzip tar.gz into APP_PATH
+ tar -C $APP_PATH -xzf $TMP_PATH
+ rm ./exponent.tar.gz
+fi
diff --git a/bin/postInstall b/bin/postInstall
new file mode 100755
index 0000000..af540d2
--- /dev/null
+++ b/bin/postInstall
@@ -0,0 +1,40 @@
+#!/usr/bin/env node
+
+const childProcess = require("child_process")
+const os = require("os")
+
+/**
+ * Do all things that need to be done after installing packages
+ *
+ * Yes, it slows down package installation a little, but it's nice to not
+ * have to remember these extra steps.
+ */
+;[
+ // Patch all the necessary modules.
+ { command: "npx patch-package" },
+
+ // Make sure we're set up correctly
+ { command: "solidarity" },
+
+ // Kill the metro bundler if it's running.
+ { command: 'pkill -f "cli.js start" || set exit 0', onlyPlatforms: ["darwin", "linux"] },
+ // Help wanted: Add the windows version here. { command: "????", onlyPlatforms: ["win32"] },
+
+ // Make sure our native modules are androidX-happy
+ { command: "jetify" },
+
+ // on iOS, make sure our native modules are installed
+ { command: "pod install", cwd: "ios", onlyPlatforms: ["darwin"] },
+]
+ .filter(({ onlyPlatforms }) => !onlyPlatforms || onlyPlatforms.includes(os.platform()))
+ .forEach((commandAndOptions) => {
+ const { command, onlyPlatform: _, ...options } = commandAndOptions
+ try {
+ childProcess.execSync(command, {
+ stdio: "inherit",
+ ...options,
+ })
+ } catch (error) {
+ process.exit(error.status)
+ }
+ })
diff --git a/bin/setup b/bin/setup
new file mode 100755
index 0000000..5711b92
--- /dev/null
+++ b/bin/setup
@@ -0,0 +1,112 @@
+#!/usr/bin/env bash
+#
+# Setup Script
+#
+# Runs all the needed commands to set up a developer's system to run this app.
+# Customize this as your app grows.
+
+# Check for macOS
+if [[ ! "$OSTYPE" =~ ^darwin ]]; then
+ echo "This script only works on macOS"
+ exit 1
+fi
+
+# Check for Homebrew
+command -v brew >/dev/null 2>&1 || {
+ echo "This setup script requires Homebrew, but it was not found on your system."
+ echo "Install it using the instructions at https://brew.sh/"
+ exit 1
+}
+
+# Ensure CocoaPods is installed
+command -v pod >/dev/null 2>&1 || {
+ echo "This app requires CocoaPods to run, but it was not found on your system."
+ echo "Install it using the instructions at https://guides.cocoapods.org/using/getting-started.html#installation"
+ exit 1
+}
+
+# Ensure Node.js is installed
+command -v npm >/dev/null 2>&1 || {
+ echo "This app requires Node.js to run, but it was not found on your system."
+ echo "Installing node with brew..."
+ brew install node
+}
+
+# Ensure Watchman is installed
+command -v watchman >/dev/null 2>&1 || {
+ echo "This app requires Watchman to watch file changes, but it was not found on your system."
+ echo "Installing watchman with brew..."
+ brew install watchman
+}
+
+# Ensure Yarn is installed
+command -v yarn >/dev/null 2>&1 || {
+ echo "This app requires Yarn package manager, but it was not found on your system."
+ echo "Installing yarn with brew..."
+ brew install yarn
+}
+
+# Ensure react-native-cli is installed
+command -v react-native >/dev/null 2>&1 || {
+ echo "This app requires react-native-cli, but it was not found on your system."
+ echo "Installing react-native-cli globally with yarn..."
+ yarn global add react-native-cli
+}
+
+# IF NEEDED: Ensure appleSimUtils is installed
+# command -v applesimutils >/dev/null 2>&1 || {
+# echo "This app requires appleSimUtils to run end to end tests, but it was not found on your system."
+# echo "Installing applesimutils with brew..."
+# brew tap wix/brew
+# brew install applesimutils
+# }
+
+# IF NEEDED: Ensure detox-cli is installed
+# command -v detox >/dev/null 2>&1 || {
+# echo "This app requires detox-cli to run end to end tests, but it was not found on your system."
+# echo "Installing detox globally with npm..."
+# npm install -g detox-cli
+# }
+
+# IF NEEDED: Ensure phraseapp is installed
+# command -v phraseapp >/dev/null 2>&1 || {
+# echo "This app requires phraseapp to run localizations, but it was not found on your system."
+# echo "Installing phraseapp with brew..."
+# brew tap phrase/brewed
+# brew install phraseapp
+# }
+
+echo "----------------------------------------------------------"
+echo "Installing NPM Packages with Yarn"
+echo "----------------------------------------------------------"
+
+yarn || { echo "NPM Packages could not be installed!"; exit 1; };
+
+echo "----------------------------------------------------------"
+echo "Installing CocoaPods"
+echo "----------------------------------------------------------"
+
+cd ios/ && {
+ pod install || { echo "CocoaPods could not be installed!"; exit 1; };
+ cd -
+}
+
+# IF NEEDED
+# echo "----------------------------------------------------------"
+# echo "Running localizations"
+# echo "----------------------------------------------------------"
+
+# bin/localize
+
+echo "----------------------------------------------------------"
+echo "Running tests to verify setup is complete"
+echo "----------------------------------------------------------"
+
+yarn test || { exit 1; }
+
+echo "----------------------------------------------------------"
+echo "Setup complete!"
+echo "----------------------------------------------------------"
+
+echo "To run the app on iOS:"
+echo "react-native run-ios" \ No newline at end of file