Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
MrArnoldPalmer authored Jun 29, 2020
2 parents 26c971d + a216739 commit 6035523
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export NODE_OPTIONS="--max-old-space-size=4096 ${NODE_OPTIONS:-}"

echo "============================================================================================="
echo "installing..."
yarn install --frozen-lockfile
yarn install --frozen-lockfile --network-timeout 1000000

fail() {
echo "❌ Last command failed. Scroll up to see errors in log (search for '!!!!!!!!')."
Expand Down
29 changes: 21 additions & 8 deletions scripts/builddown
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
#!/bin/bash
set -euo pipefail
scriptdir=$(cd $(dirname $0) && pwd)

echo "************************************************************"
echo " builddown usage:"
echo " - execute 'builddown --resume' to resume after failure"
echo " - execute 'builddown' to restart the build from the start"
echo ""
echo " for advanced usage, see ${scriptdir}/foreach.sh"
echo "************************************************************"

if ! [ -x "$(command -v yarn)" ]; then
echo "yarn is not installed. Follow the guide to install yarn - https://yarnpkg.com/en/docs/install."
exit 1
if [ "$#" -eq 0 ]; then
${scriptdir}/foreach.sh --reset
else
if [ "$1" != "--resume" ]; then
echo "Unknown option: $1"
exit 1
fi
fi

export NODE_OPTIONS="--max-old-space-size=4096 ${NODE_OPTIONS:-}"
${scriptdir}/foreach.sh --down yarn build
${scriptdir}/foreach.sh --reset

scriptdir=$(cd $(dirname $0) && pwd)
export PATH=$(cd $scriptdir && npm bin):$PATH
scope=$(${scriptdir}/current-scope)
exec lerna run ${1:-build} --scope ${scope} --include-dependents
echo "************************************************************"
echo "builddown done"
echo "************************************************************"
26 changes: 18 additions & 8 deletions scripts/foreach.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
# to run the command only against the current module and its dependencies:
# foreach.sh --up COMMAND
#
# to run the command only against the current module and its consumers:
# foreach.sh --down COMMAND
#
# --------------------------------------------------------------------------------------------------
set -euo pipefail
scriptdir=$(cd $(dirname $0) && pwd)
Expand Down Expand Up @@ -61,17 +64,24 @@ if [[ "${1:-}" == "--skip" ]]; then
exit 0
fi

up=""
up_desc=""
if [[ "${1:-}" == "--up" ]]; then
direction=""
direction_desc=""
if [[ "${1:-}" == "--up" || "${1:-}" == "--down" ]]; then
if [ ! -f package.json ]; then
echo "--up can only be executed from within a module directory (looking for package.json)"
echo "--up or --down can only be executed from within a module directory (looking for package.json)"
exit 1
fi

scope=$(node -p "require('./package.json').name")
up=" --scope ${scope} --include-dependencies"
up_desc="('${scope}' and its dependencies)"

if [[ "${1:-}" == "--up" ]]; then
direction=" --scope ${scope} --include-dependencies"
direction_desc="('${scope}' and its dependencies)"
else # --down
direction=" --scope ${scope} --include-dependents"
direction_desc="('${scope}' and its consumers)"
fi

shift
fi

Expand All @@ -89,8 +99,8 @@ fi
if [ ! -f "${statefile}" ] && [ ! -f "${commandfile}" ]; then
if [ ! -z "${command_arg}" ]; then
command="${command_arg}"
success "starting new session ${up_desc}"
${scriptdir}/../node_modules/.bin/lerna ls --all ${up} --toposort -p > ${statefile}
success "starting new session ${direction_desc}"
${scriptdir}/../node_modules/.bin/lerna ls --all ${direction} --toposort -p > ${statefile}
echo "${command}" > ${commandfile}
else
error "no active session, use \"$(basename $0) COMMAND\" to start a new session"
Expand Down

0 comments on commit 6035523

Please sign in to comment.