-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Standards and general maintenance (#33)
* Update general scaffolding * Upgrade devDependencies * Add standard scripts
- Loading branch information
Showing
9 changed files
with
776 additions
and
562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
network-timeout 30000 | ||
save-prefix "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Fail if anything in here fails | ||
set -e | ||
|
||
# This script runs from the project root | ||
cd "$(dirname "$0")/.." | ||
|
||
source scripts/helpers.sh | ||
|
||
################################################################################################### | ||
# Setup | ||
|
||
run_command "./scripts/check-environment.sh" | ||
run_command "yarn install" | ||
|
||
################################################################################################### | ||
# Run all read-write scripts and read-only scripts. This is overkill and duplicates some work, but | ||
# also helps catch intermittent errors. Suitable for running before lunch or teatime. | ||
|
||
run_command "yarn all" | ||
run_command "yarn all:readonly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Fail if anything in here fails | ||
set -e | ||
|
||
# This script runs from the project root | ||
cd "$(dirname "$0")/.." | ||
|
||
source scripts/helpers.sh | ||
|
||
################################################################################################### | ||
# Check versions of Node, Yarn, and any other tools required | ||
|
||
# If "engines" is set in package.json, validate against its values | ||
HAS_ENGINES=$(get_json_value package.json "engines") | ||
if [ $HAS_ENGINES ]; then | ||
run_npm_command check-node-version --package --print | ||
fi | ||
|
||
# If a "node" value is not set in package.json's "engines", validate against .nvmrc | ||
HAS_ENGINES_NODE=$(get_json_value package.json "node") | ||
if [ ! $HAS_ENGINES ] || [ ! $HAS_ENGINES_NODE ]; then | ||
NODE_ACTUAL=$(echo $(node --version) | tr -d '[v:space:]') | ||
NODE_DESIRED=$(cat .nvmrc) | ||
|
||
echo "Node version: $NODE_ACTUAL" | ||
if [ $NODE_DESIRED ] && [ $NODE_ACTUAL != $NODE_DESIRED ]; then | ||
echo "Node version desired: $NODE_DESIRED" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
################################################################################################### | ||
|
||
echo "All environment checks passed!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Fail if anything in here fails | ||
set -e | ||
|
||
# This script runs from the project root | ||
cd "$(dirname "$0")/.." | ||
|
||
source scripts/helpers.sh | ||
|
||
################################################################################################### | ||
# Halt running processes and local servers | ||
|
||
if command_exists killall; then | ||
run_command killall node | ||
fi | ||
|
||
if command_exists xcrun; then | ||
run_command xcrun simctl shutdown all | ||
fi | ||
|
||
################################################################################################## | ||
# Clear caches | ||
|
||
run_npm_command jest --clearCache --config={} | ||
|
||
run_command npm cache clean --force | ||
run_command yarn cache clean | ||
|
||
if command_exists watchman; then | ||
run_command watchman watch-del-all | ||
fi | ||
|
||
run_command "rm -rf | ||
$TMPDIR/react-* | ||
" | ||
|
||
################################################################################################## | ||
# Remove generated files | ||
|
||
run_command "rm -rf | ||
.yarn | ||
coverage/ | ||
dist/ | ||
node_modules/ | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Fail if anything in here fails | ||
set -e | ||
|
||
# This script runs from the project root | ||
cd "$(dirname "$0")/.." | ||
|
||
source scripts/helpers.sh | ||
|
||
################################################################################################### | ||
# Setup: Node should already have been set up in the environment init | ||
|
||
run_command "./scripts/check-environment.sh" | ||
run_command "yarn install --frozen-lockfile" | ||
|
||
################################################################################################### | ||
# Run whatever the script in package.json wants to run | ||
|
||
run_command "yarn ci" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# These are helpful functions for the other bash scripts in this directory. | ||
# Note that this is not a runnable script itself. | ||
|
||
command_exists() { | ||
# This check is based on https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then | ||
command -v "$1" > /dev/null 2>&1 | ||
} | ||
|
||
get_json_value() { | ||
local FILE=$1 | ||
local PROPERTY=$2 | ||
|
||
echo $(cat $FILE \ | ||
| grep "\"$PROPERTY\":" \ | ||
| head -1 \ | ||
| awk -F: '{ print $2 }' \ | ||
| sed 's/[",]//g' \ | ||
| tr -d '[[:space:]]' | ||
) | ||
} | ||
|
||
# This simply echoes and then runs a command. It's just an alternative to turning on echo (set -x) | ||
run_command() { | ||
local FULL_COMMAND=$* | ||
|
||
echo "$FULL_COMMAND" | ||
$FULL_COMMAND | ||
} | ||
|
||
# Given a command like `run_npm_command("jest" "--version")`, this will look for a directly-runnable command | ||
# (i.e., "jest" if you have jest-cli installed) but also fall back to using npx to run the desired command if you don't. | ||
run_npm_command() { | ||
local EXEC=$1 | ||
local FULL_COMMAND=$* | ||
|
||
if command_exists "$EXEC"; then | ||
run_command $FULL_COMMAND | ||
else | ||
run_command npx $FULL_COMMAND | ||
fi | ||
} |
Oops, something went wrong.